In the example, you'll learn how to create and access a subview on UIView.
Syntax of adding subview at UIView.
- (void)addSubview:(UIView *)view;
Creating and accessing a subview : In the example we are creating & adding a UIImageView on the UIView as a subview programatically. The method can be written into the "viewDidLoad" method that do the additional setup after the loading view.
a simple example:
- (void)viewDidLoad {
[super viewDidLoad];
UIImage *one = [UIImage imageNamed:@"imagename.png"];
UIImage *two = [UIImage imageNamed:@"Krishna_Arjuna.png"];
//Creating a subview
UIImageView *imageView1 = [[[UIImageView alloc] initWithImage:one] autorelease];
UIImageView *imageView2 = [[[UIImageView alloc] initWithImage:two] autorelease];
imageView2.alpha = 0;
//Adding subview
[self.view addSubview:imageView1];
[self.view addSubview:imageView2];
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.