iOS UIButton布局

控制按钮内部的子控件对齐。不是用contentMode,使用以下两个属性:

self.testBtn.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;

self.testBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
storyBoard中调试

控件内部子控件之间的间距


self.testBtn.contentEdgeInsets = UIEdgeInsetsMake(10, 0, 0, 0);

self.testBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);

self.testBtn.imageEdgeInsets  =UIEdgeInsetsMake(0, 0, 0, 10);

你可能感兴趣的:(iOS UIButton布局)