首页 > 代码库 > UIButton左边图片右边文字的做法
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个参数是上边界,左边界,下边界,右边界。
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。