【问题标题】:Fold/curl edge of UIImageViewUIImageView 的折叠/卷曲边缘
【发布时间】:2012-09-11 20:13:56
【问题描述】:

我需要折叠/展开 UIImageView 的边缘以标记为收藏。我搜索了多个网站,但没有找到任何相关信息。

我附上了一些示例图片,如果可能的话,附上动画效果。

【问题讨论】:

    标签: ios iphone uiimageview


    【解决方案1】:

    一种方法是使用 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

    【讨论】:

      【解决方案2】:

      可以使用UIViewControllerpresentModalViewController:animated: 并将modalTransistionStyle 设置为UIModalTransitionStylePartialCurl 来完成。见apple's docs

      【讨论】:

      • 凯,谢谢,但是UIImageView的任何边缘的折叠效果应该很小,所以我不能使用默认动画。
      【解决方案3】:
      @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
          }
      }
      

      【讨论】:

      • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
      猜你喜欢
      • 2017-04-14
      • 2018-10-30
      • 1970-01-01
      • 1970-01-01
      • 2018-08-12
      • 1970-01-01
      • 2014-09-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多