我试图在没有屏幕动画的情况下获得动画幻灯片。我只希望图像滑入它的容器框架中,好像你正在看一个有窗户的墙,有人走过窗户。
let image = self.overlayImageView[cell1]
image.clipsToBounds = true
image.center.x -= image.bounds.width
UIView.animateWithDuration(0.75, animations: { () -> Void in
image.center.x += image.bounds.width
}) { (Bool) -> Void in
//completion handler
}
更新:
cell.clipsToBounds = true
button.clipsToBounds = true
let image = UIImage(named: answeredCorrectlyImage)
button.addSubview(cell) //this was all that was missing
cell.center.x -= cell.bounds.width
if users == 1...5 && cell.hidden == true {
button.enabled = false
cell.hidden = false
cell.image = image
UIView.animateWithDuration(2.0, animations: { () -> Void in
cell.center.x += cell.bounds.width
})
答案 0 :(得分:1)
您需要将image
剪辑到其父级边界。目前,您将图像设置为剪切到边界。如果您在此视图中移动图像图层,这将起作用,但由于您尝试移动图像视图,因此您需要让父级剪切它。