ios - Using CAShapeLayer fill color issue -
i want draw circle text inside.unable display text.any help?
below image ref. expected behaviour.
below code reference:
uilabel *lbltitle = [[uilabel alloc]initwithframe:cgrectmake(100, 40, 40, 40)]; lbltitle.text = @"me"; lbltitle.textcolor = [uicolor blackcolor]; lbltitle.font = [uifont fontwithname:@"helveticaneuelight" size:10.0] ; lbltitle.textalignment = nstextalignmentcenter; [view addsubview:lbltitle]; cashapelayer *circlelayer = [cashapelayer layer]; circlelayer.path = [uibezierpath bezierpathwithovalinrect:cgrectmake(0, 0, 40, 40)].cgpath; circlelayer.fillcolor = [uicolor clearcolor].cgcolor; circlelayer.fillcolor = [uicolor colorwithred:56.0/255.0 green:212.0/255.0 blue:203.0/255.0 alpha:1.0f].cgcolor; circlelayer.strokecolor = [uicolor blackcolor].cgcolor; circlelayer.linewidth = 1; [lbltitle.layer addsublayer:circlelayer];
you can setting cornerradius of uilabel
@sujay said:
uilabel *lbltitle = [[uilabel alloc]initwithframe:cgrectmake(100, 80, 40, 40)]; lbltitle.text = @"me"; lbltitle.textcolor = [uicolor blackcolor]; lbltitle.layer.borderwidth = 1; lbltitle.layer.bordercolor = [uicolor blackcolor].cgcolor; lbltitle.layer.cornerradius = lbltitle.bounds.size.height / 2; lbltitle.layer.maskstobounds = yes; lbltitle.backgroundcolor = [uicolor colorwithred:56.0/255.0 green:212.0/255.0 blue:203.0/255.0 alpha:1.0f]; lbltitle.font = [uifont fontwithname:@"helveticaneuelight" size:10.0] ; lbltitle.textalignment = nstextalignmentcenter; [self.view addsubview:lbltitle];
Comments
Post a Comment