//创建UIButton并设置约束
UIButton *moreButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self addSubview:moreButton];
[moreButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo (_titlesLabel);
make.right.mas_equalTo (self).offset(-EDGE_WIDTH);
make.width.mas_equalTo (60 * KWIDTH_IPHONE6_SCALE);
make.height.mas_equalTo (24 * KHEIGHT_IPHONE6_SCALE);
}];
//设置button属性
moreButton.backgroundColor = [UIColor whiteColor];
[moreButton setTitle:@"更多" forState:UIControlStateNormal];
moreButton.titleLabel.font = [UIFont pingFang_RegularWithSize:14.0];
[moreButton setTitleColor:[UIColor color102] forState:UIControlStateNormal];
[moreButton setImage:[UIImage imageNamed:@"arrowGrayRight"] forState:UIControlStateNormal];
//设置内部文字 图片位置 文字左 图片右
[moreButton setTitleEdgeInsets:UIEdgeInsetsMake(0, -moreButton.imageView.bounds.size.width*1.2, 0, moreButton.imageView.bounds.size.width)];
[moreButton setImageEdgeInsets:UIEdgeInsetsMake(0, moreButton.titleLabel.bounds.size.width*1.2, 0, -moreButton.titleLabel.bounds.size.width)];
[moreButton addTarget:self action:@selector(moreButtonAction) forControlEvents:UIControlEventTouchUpInside];
UIbutton文字左 图片右
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 一、前言 关于苹果的布局一直是我比较纠结的问题,是写代码来控制布局,还是使用storyboard来控制布局呢?以前...
- iOS_autoLayout_Masonry 概述 Masonry是一个轻量级的布局框架与更好的包装AutoLay...