UIButton 图标 变扁 保持比例方法


- (UIButton *)reply {
    if (_reply == nil) {
        _reply = [[UIButton alloc] init];
        [_reply setTitleColor:[UIColor colorWithRed:0.53 green:0.53 blue:0.53 alpha:1.00] forState:(UIControlStateNormal)];
        [_reply setTitle:@"回复" forState:(UIControlStateNormal)];
        [_reply.titleLabel setFont:[UIFont systemFontOfSize:12]];
        
        
        //  这两句↓
        [_reply setImage:[UIImage imageNamed:@"ic_sms"] forState:UIControlStateNormal];
        [_reply.imageView setContentMode:UIViewContentModeScaleAspectFit];
        // 到这 ↑
        
        // 这句可以调整图标位置↓
        [_reply setImageEdgeInsets:UIEdgeInsetsMake(0, 10, 0, 0)];
        // 这句可以调整图标位置↑
        
        
        [_reply addTarget:self action:@selector(tapReply:) forControlEvents:(UIControlEventTouchUpInside)];
        
    }
    return _reply;
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容