在平常我们使用button的时候,需求可能是需要我们满足button的Image和Label的各种体位,这个使用我们就需要使用UIEdgeInsetsMake来满足下需求,通过设置button的image和label的insetEdge来满足。
UIEdgeInsetsMake 介绍
typedef struct UIEdgeInsets {
CGFloat top, left, bottom, right; // specify amount to inset (positive) for each of the edges. values can be negative to 'outset'
} UIEdgeInsets;
是一个结构体,里面有四个属性,上左下右,看注释大概意思是说
为每条边指定插入量。正值的话是距离边多多少,负值的话是距离边少多少
引用:
图中,蓝色标识为可变区域, 绿色标识为不变区域。UIEdgeInsets结构体的属性top与bottom为一对,用来指定纵向可变区域(黑色虚线矩形),left与right为一对,用来指定横向可