Send UIImageView (label background) to back to display UILabel -
i trying add image background uilabel, uilabel's title cannot seen, though tried send background image back. code below , advice on how great, thanks!
uiimageview *labelbackground = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"image.png"]]; [mylabel addsubview:labelbackground]; [mylabel sendsubviewtoback:labelbackground]; mylabel.backgroundcolor = [uicolor clearcolor]; [mylabel settext:title];
when add view (your image view) subview view (your label), subview in front of superview. either need siblings:
[mycontainer addsubview:labelbackground]; [mycontainer addsubview:mylabel];
or better yet, label should subview of image view:
[labelbackground addsubview:mylabel]; [mycontainer addsubview:labelbackground];
another solution might use image background color label:
[mylabel setbackgroundcolor:[uicolor colorwithpatternimage:myuiimage]];
but note image repeated instead of centered or stretched.
Comments
Post a Comment