标签:
UIImage *buttonImg = [button imageForState:UIControlStateNormal]; CGFloat titleWidth = [button.titleLabel.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont boldSystemFontOfSize:18],NSFontAttributeName, nil]].width; [button setTitleEdgeInsets:UIEdgeInsetsMake(buttonImg.size.height, -buttonImg.size.width, 0, 0)]; [button setImageEdgeInsets:UIEdgeInsetsMake(-15, 0, 0, -titleWidth)];
效果如下。俩个图不对称是因为图片大小不同。
标签:
原文地址:http://www.cnblogs.com/mlgbya/p/4302837.html