I just put my logic.
- your view has been display 4 images (with different shape) so you need to take 4
UIImageView
in .h file and one UIView
name is ImgContainerView in .h file
make sure that your all button has same action method and give all button to it's tag. for example each button has method name is
-(void) buttonMethodName:(UIButton *) sender
Then you need to create one method name is,
-(void)setUpimagesByselectedButton:(int) buttonTag
Call this method in button's action method, such like
-(void) buttonMethodName:(UIButton *) sender
{
[self setUpimagesByselectedButton:sender.tag]; // pass button's tag as parameter.
}
Here now in method,
-(void)setUpimagesByselectedButton:(int) buttonTag
{
// first you need to remove all subview of ImgContainerView
if(self.ImgContainerView)
{
for(UIView *subview in self.ImgContainerView.subviews)
[subview removeFromSuperview];
[self.ImgContainerView removeFromSuperview]; self.ImgContainerView = nil;
}
// Then re-create ImgContainerView with background color is white;
// add all UIImageView as subView of ImgContainerView;
// and then set FRAME of your UIImageView base on selected button's tag such like.
if(buttonTag == 1)// for ex. i take 1, here you write your button's tag.
self.imageView1.frame....
// create one by one imageView and set it's frame by put condition as above
// your UIImageView's contentMode should be UIViewContentModeScaleAspectFill or UIViewContentModeCenter;
}
When you tap any button then each time ImgContainerView
is re-created with it's particular shape.