profile for monkeydom at Stack Overflow, Q&A for professional and enthusiast programmers

cocoa-dom

coding bits I use, come across, like, hate, the whole shebang.

twitter | github | mastodon     rant-dom     rss | archive

Permalink
Home

UIEdgeInsets

A common task for UIKit devs: Inset a CGRect by an amount from each edge:

UIEdgeInsetsInsetRect(rect,insets);

And to do that in one line of course the constructor of UIEdgeInsets

UIEdgeInsetsMake(top,left,bottom,right);

Why on earth they decided to make the order of insets the other way round as CSS will remain a mystery. Also note that a negative inset expands towards this edge. E.g.

UIEdgeInsetsInsetRect(CGRectMake(0,0,100,100), UIEdgeInsetsMake(10,10,-50,50))

results in the following CGRect: {10,10,140,40}