<分区>
如何在 iPhone 中制作图像拼贴。我已经给出了图像,底部有不同的形状,根据这些形状我想改变图像。所以请帮助我任何人。非常感谢,我将非常感谢您的努力和帮助。非常感谢…………
我试过这些链接 How to make a view resize on swipe within a photo collage for iOS?
标签 ios iphone objective-c
<分区>
如何在 iPhone 中制作图像拼贴。我已经给出了图像,底部有不同的形状,根据这些形状我想改变图像。所以请帮助我任何人。非常感谢,我将非常感谢您的努力和帮助。非常感谢…………
我试过这些链接 How to make a view resize on swipe within a photo collage for iOS?
最佳答案
我只是说说我的逻辑。
UIImageView
和一个 UIView
name is ImgContainerView in .h file确保您的所有按钮都具有相同的操作方法并将所有按钮赋予它的标签。例如每个按钮的方法名称是
-(void) buttonMethodName:(UIButton *) sender
然后你需要创建一个方法名是,
-(void)setUpimagesByselectedButton:(int) buttonTag
在按钮的action方法中调用该方法,例如
-(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
都会重新创建它的特定形状。
关于ios - 如何根据不同的形状拼贴图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21619968/