UIButton 图片文字上下对齐
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)];
效果如下。俩个图不对称是因为图片大小不同。