[IOS] on the use of Masonry cut fillet invalid

In use today masnory wrote a list, discovered a problem. That is, after use masonry view settings found set does not work any angular fillets.

This is because after the use of masonry, view the fream and bounds are 0, so set the fillet will not work.

Solution: 
When you set up the constraint control, call layoutIfNeeded layout function, the controls will then be bound in accordance with the constraints, generating a corresponding frame and the layout of the current bounds. So that you can take advantage of these two properties to cut rounded picture
  [Self layoutIfNeeded]; // this code is very important, you can not forget 
  [Self useBezierPathClipCornerWithType: UILayoutCornerRadiusTop WithCornerRadius: AdaptedWidth ( . 5 )];

Attach the following update on the difference between autolayout several methods:

setNeedsLayout: tells the page needs to be updated, but the update will not start immediately. Calls layoutSubviews immediately after execution. 
layoutIfNeeded: Page Layout update immediately informed. It is usually used together and setNeedsLayout. If you want to generate a new frame immediately you need to call this method, the use of this general layout animation can use this method to make the animation take effect directly after updating the layout. 
layoutSubviews: rewrite the system layout 
setNeedsUpdateConstraints: inform constraints need to be updated, but will not begin immediately 
updateConstraintsIfNeeded: inform immediately update constraint 
updateConstraints: restraint system update

 

Guess you like

Origin www.cnblogs.com/weicyNo-1/p/11129356.html