objective c - Define background Image with UIImage -


i'm using header file set background application. have like:

#define backgroundimage [uicolor colorwithpatternimage:[uiimage imagenamed:@"background.jpeg"]] 

but want use uiimageview instead of uicolor. know can do:

uiimageview *imageview = [[uiimageview alloc] initwithframe:cgrectmake(0, 0, 320, 480) [imageview setimage:[uiimage imagenamed:@"background.png"]]; self.tableview.backgroundview = imageview; 

but how use #define?

#define preprocessor directive. going anywhere use backgroundimage [uicolor colorwithpatternimage:[uiimage imagenamed:@"background.jpeg"]]

the best way handle use #define specify image name:

#define kbackgroundimage @"background.png" 

and use in code:

// use table view bounds background view size of table view uiimageview *imageview = [[uiimageview alloc] initwithframe:self.tableview.bounds; [imageview setimage:[uiimage imagenamed:kbackgroundimage]]; self.tableview.backgroundview = imageview; 

if want however, can do:

#define kbackgroundimage [uiimage imagenamed:@"background.png"] 

and:

// use table view bounds background view size of table view uiimageview *imageview = [[uiimageview alloc] initwithframe:self.tableview.bounds;

[imageview setimage:kbackgroundimage]; self.tableview.backgroundview = imageview; 

if choose make whole code block preprocessor define, can use \ make new lines.

#define uiimageview *imageview = [[uiimageview alloc] initwithframe:self.tableview.bounds; \ [imageview setimage:[uiimage imagenamed:kbackgroundimage]]; \ self.tableview.backgroundview = imageview; 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -