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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -