ios - How to add a border to this delimited layer? -


i have image above delimitate transparent rectangle using layer , mask. i transparent rectangle red bordered. find way achieve :

here have done :

enter image description here

my viewcontroller has darkenedview property.

- (void)loadview {     uiview *const rootview = [[uiview alloc] initwithframe:cgrectmake(0, 0, 50, 50)];     rootview.backgroundcolor = [uicolor whitecolor];     self.view = rootview;     [self addcontentsubviews]; }  - (void)addcontentsubviews {     uiimageview *const imageview = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"dsc_0823.jpg"]];     imageview.contentmode = uiviewcontentmodescaleaspectfill;     imageview.frame = self.view.bounds;     imageview.autoresizingmask = uiviewautoresizingflexibleheight | uiviewautoresizingflexiblewidth;     [self.view addsubview:imageview]; }  - (void)viewdidload {     [super viewdidload];     [self adddarkenedsubview]; }  - (void)viewdidlayoutsubviews {     cgrect const bounds = self.view.bounds;     darkenedview.center = cgpointmake(cgrectgetmidx(bounds), 0); }  - (void)adddarkenedsubview {     darkenedview = [[uiview alloc] initwithframe:cgrectmake(10, 30, 400, 1200)];     darkenedview.backgroundcolor = [uicolor colorwithwhite:0.0 alpha:0.6];     darkenedview.autoresizingmask = 0;     [self.view addsubview:darkenedview];     [self addmasktodarkenedview]; }  - (void)addmasktodarkenedview {     cgrect bounds = darkenedview.bounds;     cashapelayer *masklayer = [cashapelayer layer];     masklayer.frame = bounds;      cgrect const myrect = cgrectmake(cgrectgetmidx(bounds) - 100,         cgrectgetmidy(bounds) + 100,         200, 200);     uibezierpath *path = [uibezierpath bezierpathwithrect:myrect];     [path appendpath:[uibezierpath bezierpathwithrect:bounds]];     masklayer.path = path.cgpath;     masklayer.fillrule = kcafillruleevenodd;     darkenedview.layer.mask = masklayer;  } 

i've tried without success :

masklayer.strokecolor = [uicolor redcolor].cgcolor; masklayer.linewidth = 3.0f; 

instead of giving stroke masklayer object create cashapelayer , addsublayer darkenedview view below sample code hope help

cashapelayer *shape = [cashapelayer layer]; shape.frame = darkenedview.bounds; shape.path = path.cgpath; shape.linewidth = 3.0f; shape.strokecolor = [uicolor redcolor].cgcolor; shape.fillcolor = [uicolor clearcolor].cgcolor; [darkenedview.layer addsublayer:shape]; 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -