iOS UIButton上同時加圖片和標題,設定偏移
阿新 • • 發佈:2019-01-03
[weixinbtn setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 10)];分別上向下、右、上、左偏移~~~~
//微信登入
UIButton *weixinbtn = [UIButton buttonWithType:UIButtonTypeSystem];
weixinbtn.layer.cornerRadius = 5;
weixinbtn.clipsToBounds = YES;
[weixinbtn setTitle:@"微信登入" forState:UIControlStateNormal];
[weixinbtn set TitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[weixinbtn setImage:[[UIImage imageNamed:@"weixin"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ] forState:UIControlStateNormal];
[weixinbtn setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 10)];
[weixinbtn setTitleEdgeInsets:UIEdgeInsetsMake(0 , 10, 0, 0)];
weixinbtn.backgroundColor = [UIColor colorWithHexString:@"73D7BF"];
[self addSubview:weixinbtn];