UIEdgeInsets

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_18683985/article/details/82381785
    UIEdgeInsetsMake(<#CGFloat top#>, <#CGFloat left#>, <#CGFloat bottom#>, <#CGFloat right#>)

UIEdgeInsets就是长上面的样子的.有四个属性.对应上左下右.

        UIKIT_STATIC_INLINE UIEdgeInsets UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat bottom, CGFloat right) {
        UIEdgeInsets insets = {top, left, bottom, right};
        return insets;
    }

EdgeInsets的意思差不多是边框的插入距离的意思.只需要记住用的时候正值就是往内缩.负值就是往外扩充.(UIbutton的title和image的edgeinsets和collectionview的section的edgeinsets.对于button的contentedgeinsets来说正好相反).

对于UIbutton的image和title来说,这里拿向上移动来举例子.
向上移动的距离 = - (top + bottom) / 2.所以就会有我设置top为10.bottom为0.只往上移动了5的现象.

可以用在UICollectionView的代理方法调整item的组边距等.UITableView的sepatory的线的”长宽”.UIButton的文字图片的相对关系等.

通过设置edgeInsets来改变button图文的排布方式

猜你喜欢

转载自blog.csdn.net/qq_18683985/article/details/82381785