【问题标题】:Swift Image Rotation showing 50% image快速图像旋转显示 50% 图像
【发布时间】:2016-06-28 06:17:36
【问题描述】:

我是 swift 和 iPhone 开发的新手。最近我正在研究一个我必须垂直旋转图像的主题。

我几乎解决了这个问题,但问题是我的图像在旋转,但在旋转时它显示了 50% 的图像。这是视频中问题的链接。 http://screencast.com/t/VI4yZ0a8Wr

这里也是我正在使用的代码

func animationRotationEffect(view:UIView,animationTime:Float)
{
    UIView.animateWithDuration(NSTimeInterval(animationTime), animations: { () -> Void in

        /* previously used
         same result produced as below
        var animation:CABasicAnimation = CABasicAnimation(keyPath: "transform")
        animation.toValue = NSValue(CATransform3D:CATransform3DMakeRotation(CGFloat(M_PI), 1, 0, 0))

        animation.duration = CFTimeInterval(animationTime)
        animation.cumulative = false
        animation.repeatCount  = 1
        view.layer.addAnimation(animation, forKey: nil)
        */


        let animate = CABasicAnimation(keyPath: "transform.rotation.x")
        animate.duration = CFTimeInterval(animationTime)
        animate.repeatCount = Float.infinity
        animate.fromValue = 0.0
        animate.toValue = Float(M_PI * 2.0)
        view.layer.addAnimation(animate, forKey: nil)

    })
}

如果有人可以帮助我,那将非常有帮助。

提前致谢,

尼克松

【问题讨论】:

    标签: ios xcode swift animation


    【解决方案1】:

    可能不是动画问题,试试把你的UIImageView的aspect和content mode设置成这个

    imageView.contentMode = UIViewContentMode.ScaleAspectFit
    

    更多关于 UIViewContentMode 枚举的信息here

    【讨论】:

    • 我认为这不是问题。因为我已经从情节提要中设置了 Aspect Fit。 screencast.com/t/RfoIvZP5e。还尝试了您的解决方案,但没有成功。 :(
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多