UIButton 标题靠右

时间:2022-05-23 08:47:29

_classBtn =  [UIButton buttonWithType:UIButtonTypeCustom];

_classBtn.frame = CGRectMake(  kDeviceWidth -200-30-10,  l2.top , 200, 30);

_classBtn.backgroundColor = [UIColor yellowColor];

_classBtn.titleLabel.font = [UIFont systemFontOfSize:12];

[_classBtn setTitleColor:kMainBlueColor forState:0];

[_classBtn setTitle:@"点击选择分类" forState:0];

_classBtn.contentHorizontalAlignment  =  UIControlContentHorizontalAlignmentRight; //标题靠右

[contentScrollView addSubview:_classBtn];