1. 程式人生 > >iOS UIButton 圖片和文字上下居中

iOS UIButton 圖片和文字上下居中

CGSize size1 = [titileArr[i] sizeWithFont:[UIFontsystemFontOfSize:12] constrainedToSize:CGSizeMake(MAXFLOAT, self.button.titleLabel.frame.size.height)];

self.button.titleEdgeInsets =UIEdgeInsetsMake(0.5 * image.size.height, -0.5 * image.size.width, -0.5 * image.size.height, 0.5 * image.size.width);

self

.button.imageEdgeInsets =UIEdgeInsetsMake(-0.5 * size1.height, 0.5 * size1.width, 0.5 * size1.height, -0.5 * size1.width);