如何在iPhone中制作拼贴图像。我给了图像,底部有不同的形状,根据这些形状,我想改变图像。所以请帮助我任何人。非常感谢,我将非常感谢您的努力和帮助。非常感谢.......
我尝试过这些链接 How to make a view resize on swipe within a photo collage for iOS?
答案 0 :(得分:3)
我只是把我的逻辑。
UIImageView
一个UIView
} .h 文件中确保您的所有按钮都具有相同的操作方法并将所有按钮提供给标记。例如每个按钮的方法名称为
- (void)buttonMethodName:(UIButton *)sender
然后你需要创建一个方法名称,
- (void)setUpimagesByselectedButton:(int)buttonTag
在按钮的操作方法中调用此方法,例如
-(void) buttonMethodName:(UIButton *) sender
{
[self setUpimagesByselectedButton:sender.tag]; // pass button's tag as parameter.
}
现在在方法中,
-(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;
}
当您点按任意按钮时,每次ImgContainerView
重新创建时都会显示其特定形状。