M learn Container View using objective c.
Here, try to display two container one by one using segmented Controller. Two container use container name is containerViewA, containerViewB. I am running the app that time only containerViewB is load.
Code:
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIView *containerViewA;
@property (weak, nonatomic) IBOutlet UIView *containerViewB;
@end
- (IBAction)ShowComponent:(UISegmentedControl *)sender {
if (sender.selectedSegmentIndex == 0) {
[UIView animateWithDuration:(0.5) animations:^{
self.containerViewA.alpha = 1;
self.containerViewB.alpha = 0;
}];
} else {
[UIView animateWithDuration:(0.5) animations:^{
self.containerViewA.alpha = 0;
self.containerViewB.alpha = 1;
}];
}
}
Update:
Update 1:
Storyboard side panel.
make sure @property (weak, nonatomic) IBOutlet UIView *containerViewA;
and @property (weak, nonatomic) IBOutlet UIView *containerViewB;
are connected properly.