控制按鈕內(nèi)部的子控件對齊昌执。不是用contentMode班挖,使用以下兩個屬性:
self.testBtn.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
self.testBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
控件內(nèi)部子控件之間的間距
self.testBtn.contentEdgeInsets = UIEdgeInsetsMake(10, 0, 0, 0);
self.testBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
self.testBtn.imageEdgeInsets =UIEdgeInsetsMake(0, 0, 0, 10);