iphone - How can I set maskToBounds effect on CAShapeLayer(Rounded-Recr cornered UIView)? -
i want make glow effect spread outside of thisview.
i used code make half-rounded rect cornered uivew
.
here code.
+ (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 layers in hierarchy! uiview *superview = [view superview]; [view removefromsuperview]; view.layer.mask = masklayer; [superview addsubview:view]; return view; }
and there two image buttons
in view closed boundary. if touch event happen on buttons, glow effect shows(showstouchwhenhighlighted
)
before using piece of code, used
thisview.layer.cornerradius = 8; thisview.layer.maskstobounds = no;
and glow effect spread outside of 'thisview'.
but after using cashapelayer in 'thisview' masking half-roused rect, glow effect masked boundary.
what you're seeing how mask supposed work. applying mask layer of superview. let's call view superview
(just in code). okay, do? mask superview
, sublayers. that includes subviews. subviews sublayers.
so, since buttons subviews of superview
, masked else inside superview
.
if don't want happen, don't make buttons subviews of superview
. can sit on top of superview
without being subviews, example.
Comments
Post a Comment