美文网首页iOS快速开发总结
iOS 快速UIButton 左边文字、右边按钮

iOS 快速UIButton 左边文字、右边按钮

作者: 键盘上的演绎者 | 来源:发表于2019-06-24 14:23 被阅读2次
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setImage:[UIImage imageNamed:@"image"] forState:UIControlStateNormal];
        [button setTitle:@"左边文字,右边图片" forState:UIControlStateNormal];
        [button setTitleEdgeInsets:UIEdgeInsetsMake(0, - button.imageView.image.size.width, 0, button.imageView.image.size.width)];
        [button setImageEdgeInsets:UIEdgeInsetsMake(0, button.titleLabel.bounds.size.width, 0, -button.titleLabel.bounds.size.width)];
    

    相关文章

      网友评论

        本文标题:iOS 快速UIButton 左边文字、右边按钮

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