【发布时间】:2012-09-11 20:13:56
【问题描述】:
我需要折叠/展开 UIImageView 的边缘以标记为收藏。我搜索了多个网站,但没有找到任何相关信息。
我附上了一些示例图片,如果可能的话,附上动画效果。
【问题讨论】:
标签: ios iphone uiimageview
我需要折叠/展开 UIImageView 的边缘以标记为收藏。我搜索了多个网站,但没有找到任何相关信息。
我附上了一些示例图片,如果可能的话,附上动画效果。
【问题讨论】:
标签: ios iphone uiimageview
一种方法是使用 OpenGL 为视图设置动画。有一个不错的库,叫做XBPageCurl
但是,您可以通过为卷曲效果创建遮罩并在过渡到它时为您的视图设置动画来实现更轻松的解决方案。这是它的样子
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
UIImage *maskedImage = [yourImage imageMaskedWithImage:yourMask];
[yourImageView setImage:maskedImage];
[UIView commitAnimations];
要了解如何屏蔽图像,请查看此处http://mobiledevelopertips.com/cocoa/how-to-mask-an-image.html
【讨论】:
可以使用UIViewController 的presentModalViewController:animated: 并将modalTransistionStyle 设置为UIModalTransitionStylePartialCurl 来完成。见apple's docs。
【讨论】:
@IBAction func curl(_ sender: Any, forEvent event: UIEvent) {
if b == 1 {
UIView.transition(with: imageview, duration: 1.5, options: .transitionCurlUp, animations: {self.imageview.isHidden = true}, completion: nil)
b = 2
}
else if b == 2
{
self.imageview.isHidden = false
UIView.transition(with: imageview, duration: 1.5, options: .transitionCurlDown, animations: {self.imageview.isHighlighted = true}, completion: nil)
b = 1
}
}
【讨论】: