按钮相关属性设置(按钮文字位置 和图片位置设置)
- (UIButton *)navSearBtn { if (!_navSearBtn) { _navSearBtn = [[UIButton alloc]init]; _navSearBtn.backgroundColor = [UIColor clearColor]; _navSearBtn.titleLabel.font = DEF_FontSize_14; [_navSearBtn setTitle:@"请输入关键词搜索" forState:UIControlStateNormal]; [_navSearBtn setImage:[UIImage imageNamed:@"搜索"] forState:UIControlStateNormal]; [_navSearBtn setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, -330 / WIDTH_6S_SCALE)]; //按钮中文字靠最左边 // _navSearBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; //根据需求调整按钮中文字位置 [_navSearBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -120 / WIDTH_6S_SCALE, 0, 0)]; _navSearBtn.layer.borderColor = [UIColor whiteColor].CGColor; _navSearBtn.layer.borderWidth = 1; [_navSearBtn addTarget:self action:@selector(navSearBtnAction:) forControlEvents:UIControlEventTouchUpInside]; _navSearBtn.layer.cornerRadius = 5 / HEIGHT_6S_SCALE; _navSearBtn.layer.masksToBounds = YES; } return _navSearBtn; }
相关推荐
定格 2020-03-28
lijiexiaoge 2019-06-26
Jplane 2019-06-20
kunpengapple 2019-06-20
liuwentao 2014-04-01
UIcircle 2017-12-19
Jacinth 2017-11-29
手机APP开发 2016-11-24
手机开发 2016-10-21