Search code examples
iosdebuggingmasonryobjective-c-category

get frame of a view after use mas_makeConstraints


Masonry is a useful framework in iOS.And I want to use it to make a category for UIView.

But after using the function "mas_makeConstraints()" to set the frame ,I can't get the frame of the view.The frame of the view still is {0,0,0,0}.

So when does the value change in the program? or what the basic principle in Masonry? Or how can I get the frame in debugging?


Solution

  • Calling mas_makeConstraints on your view simply adds constraints to it. Your view's frame will be updated during next layout cycle, not immediately. In order to force layout, you can try calling layoutIfNeeded on your view instance after setting up constraints.