I want to make the glow effect spread outside of thisView.
我用这段代码来制作Half-Rounded rect cornered UIVew
.
这是我的代码。
+ (UIView *)makeUpperHalfRoundedView:(UIView *)view {
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.frame = view.bounds;
UIBezierPath *roundedPath =
[UIBezierPath bezierPathWithRoundedRect:maskLayer.bounds
byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
cornerRadii:CGSizeMake(8.f, 8.f)];
maskLayer.fillColor = [[UIColor blackColor] CGColor];
maskLayer.backgroundColor = [[UIColor clearColor] CGColor];
maskLayer.path = [roundedPath CGPath];
// maskLayer.masksToBounds = NO;
//Don't add masks to layers already in the hierarchy!
UIView *superview = [view superview];
[view removeFromSuperview];
view.layer.mask = maskLayer;
[superview addSubview:view];
return view;
}
并且two image buttons
在这种观点中存在封闭的边界。如果按钮上发生触摸事件,发光效果显示(showsTouchWhenHighlighted
)
在使用这段代码之前,我只是使用了
thisView.layer.cornerRadius = 8;
thisVIew.layer.masksToBounds = NO;
并且发光效果散布在“thisView”之外。
但是在“thisView”中使用 CAShapeLayer 来掩盖半被唤醒的矩形后,发光效果被边界掩盖了。