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;
}

你可能感兴趣的:(UIButton 图标 变扁 保持比例方法)