`
lizhuang
  • 浏览: 904316 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

UIButton左边图片右边文字的做法

 
阅读更多
 UIImage *yuyinImage = [UIImage imageNamed:@"yuyin.png"];
    [soundButton setImage:yuyinImage forState:UIControlStateNormal];
    [soundButton setImage:yuyinImage forState:UIControlStateSelected];
    [soundButton setImage:yuyinImage forState:UIControlStateHighlighted];
    //top left bottom right
    [soundButton setImageEdgeInsets:UIEdgeInsetsMake(5, 5, 5, 15)];

NSString *soundButtonTitle = @"语音";
    [soundButton setTitle:soundButtonTitle forState:UIControlStateNormal];
    [soundButton setTitle:soundButtonTitle forState:UIControlStateSelected];
    [soundButton setTitle:soundButtonTitle forState:UIControlStateHighlighted];
    [soundButton setTitleEdgeInsets:UIEdgeInsetsMake(5, 10, 5, 0)];

[myButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)]; 4个参数是上边界,左边界,下边界,右边界。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics