- (void)viewDidLoad {
        [super viewDidLoad];
        /*
         UIButton设置对应的边距image跟title的边距属性
            titleEdgeInsets     内边距
            contentEdgeInsets   外边距
         */
        // {top, left, bottom, right}
        _twoBut.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 10);
     
        _threeBut.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 10);
        
        _fourBut.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 10);
        _fourBut.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 10);
        
        _fiveBut.imageEdgeInsets = UIEdgeInsetsMake(10, 10, 0, 0);
     
        _sixBut.imageEdgeInsets = UIEdgeInsetsMake(0, _sixBut.titleLabel.intrinsicContentSize.width, 0, -_sixBut.titleLabel.intrinsicContentSize.width);
        _sixBut.titleEdgeInsets = UIEdgeInsetsMake(0, -_sixBut.currentImage.size.width, 0, _sixBut.currentImage.size.width);
    }
[iOS]UIButton内、外边距设置-LMLPHP

05-16 08:04