ios - Add image to view (background) -


i have added image viewcontroller in code. without use of imageview. how did it:

uiimageview *backgroundimage =[[uiimageview alloc] initwithframe:cgrectmake(50,50,100,500)]; backgroundimage.image=[uiimage imagenamed:@"backgroundimage"]; [self.view addsubview:backgroundimage]; 

there 2 things need litte with. how can image of view, behind labels, buttons etc. , how image fit iphone screen sizes? hope can me. thanks

as asked 2 questions-

question 1 : how labels/ buttons other subviews visible on image?

answer -

just add image before other subview.

and there 2 ways set background image uiview

you can set view background color color created uicolor’s colorwithpaternimage. can add uiimageview subview view.

colorwithpaternimage created use small images create pattern image repeated. using large images wont wise decision. if want have patterned image background uses small images repeated fill background, should use colorwithpaternimage, , wont consume memory.

self.view.backgroundcolor = [uicolor colorwithpatternimage:[uiimage imagenamed:@"background"]]; 

if have full size background image, should use uiimageview. using uiimageview save lot of memory in case.

uiimageview *backgroundview = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"background"]]; [self.view addsubview:backgroundview]; 

question 2 : how show image per device/ screen resolution?

answer -

cgrect screenbounds = [[uiscreen mainscreen] bounds];  

use above screenbounds set frame of imageview.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -