美文网首页iOS Developer
iOS UIButton 实现 左边文字 右边图片

iOS UIButton 实现 左边文字 右边图片

作者: 字母大师 | 来源:发表于2017-01-13 11:57 被阅读0次
-(void)layoutSubviews
{
 
    [super layoutSubviews];
    /** 修改 title 的 frame */
    // 1.获取 titleLabel 的 frame
    CGRect titleLabelFrame = self.titleLabel.frame;
    // 2.修改 titleLabel 的 frame
    titleLabelFrame.origin.x = 0;
    // 3.重新赋值
    self.titleLabel.frame = titleLabelFrame;
    
    /** 修改 imageView 的 frame */
    // 1.获取 imageView 的 frame
    CGRect imageViewFrame = self.imageView.frame;
    // 2.修改 imageView 的 frame
    imageViewFrame.origin.x = titleLabelFrame.size.width+10;
    // 3.重新赋值
    self.imageView.frame = imageViewFrame;
}

相关文章

网友评论

    本文标题:iOS UIButton 实现 左边文字 右边图片

    本文链接:https://www.haomeiwen.com/subject/khqsbttx.html