Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于使用<Masonry>添加约束时,使用扩展绘制圆角的问题 #46

Open
MrBugDou opened this issue Jul 20, 2018 · 0 comments
Open

Comments

@MrBugDou
Copy link

我的项目使用了进行布局,添加完约束,在调用 [UIView jk_setRoundedCorners:radius] 方法为视图添加圆角的时,无法正常添加,建议将该扩展下的方法实现改为:

[self layoutIfNeeded];//增加这一行代码,其他维持不变

CGRect rect = self.bounds;

// Create the path
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:rect
                                               byRoundingCorners:corners
                                                     cornerRadii:CGSizeMake(radius, radius)];

// Create the shape layer and set its path
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.frame = rect;
maskLayer.path = maskPath.CGPath;

// Set the newly created shape layer as the mask for the view's layer
self.layer.mask = maskLayer;

其他类似的地方都应该添加这个代码

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant