iOS UIButton上同時加圖片和標題,設置偏移

[weixinbtn setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 10)];分別上向下、右、上、左偏移~~~~

//微信登錄
    UIButton *weixinbtn = [UIButton buttonWithType:UIButtonTypeSystem];
    weixinbtn.layer.cornerRadius = 5;
    weixinbtn.clipsToBounds = YES;
    [weixinbtn setTitle:@"微信登錄" forState:UIControlStateNormal];
    [weixinbtn setTitleColor:[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];
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章