UIbutton文字左 图片右

//创建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文字左 图片右)