Reputation: 85
I need to implement this functionality.Any one can you give the sample code.Suggest me. Thanks in advance
Upvotes: 0
Views: 132
Reputation: 142
First, make sure that your image is in your xcode project.
Then add it to your code by referencing it as a UIImage:
UIImage *myimg = [UIImage imageNamed:@"AppleUSA1.jpg"]
Then create a UIImageView to
UIImageView *imgview = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 300, 400)];//creates the view and positions its frame
[imgview setImage:myimg];//Assigns the image to our view
[imgview setContentMode:UIViewContentModeScaleAspectFit];
[self.view addSubview:imgview];//adds the view to the screen
For more info, see http://www.tutorialspoint.com/ios/ios_ui_elements_imageview.htm
Upvotes: 1