2

I am trying to create a list of UIEdgeInsets instances in Objective-C. Since they are not id type, I couldn't add them into an array.

What I want to do is something like this:

NSArray *contentInsets = @[{10, 20, 30, 40}, {10, 10, 10, 10}, ...];

Thanks.

4

1 回答 1

3

您可以使用以下方法将 UIEdgeInsets 存储在 NSArray 中:

NSStringFromUIEdgeInsets

例如:

NSArray *contentInsets = @[NSStringFromUIEdgeInsets(UIEdgeInsetsMake(10, 20, 30, 40)), NSStringFromUIEdgeInsets(UIEdgeInsetsMake(10, 10, 10, 10)), ...];

并取回:

UIEdgeInsetsFromString
于 2015-03-19T03:48:12.517 回答