[英]How to make UIView not appear on background but still appear over a UIImageView (subview)
I have a UIImageView. 我有一个UIImageView。 I also have a view. 我也有看法。 I want the view to appear on top of the UIImageView as it animates across the screen. 我希望视图在整个屏幕上设置动画时显示在UIImageView的顶部。 I DO NOT want the view to appear in the background though. 我不希望视图出现在背景中。
How can I do this? 我怎样才能做到这一点?
I have tried changing the order of subviews by adding another subview however this is impossible to do. 我试图通过添加另一个子视图来更改子视图的顺序,但这是不可能的。
I was considering using a layer rather than a view to animate however the UIImageView has transparent portions around it. 我正在考虑使用图层而不是视图进行动画处理,但是UIImageView周围具有透明部分。
Code: (note: isAnimating is a class property, don't worry about it) 代码:(注意:isAnimating是一个类属性,不必担心)
@IBAction func AnimateBtnTapped(sender: AnyObject) {
if (isAnimating == false) {
isAnimating = true
UIView.animateWithDuration(0.6, delay: 0.0, options: .Repeat, animations: {
self.glintImageConstraint.constant += 450
self.view.layoutIfNeeded()
}, completion: nil)
} else {
isAnimating = false
self.glintImageView.layer.removeAllAnimations() //stop animation
self.glintImageConstraint.constant = -200 //set glintImage to original position
self.view.layoutIfNeeded()
}
}
My UIImageView is a medallion. 我的UIImageView是纪念章。 The glintImageView is the object animation across on top of it. glintImageView是其上方的对象动画。
EDIT: I am asking for an equivalent to Shimmer ( https://github.com/facebook/Shimmer ) however for UIImageView. 编辑:我要求等效于Shimmer( https://github.com/facebook/Shimmer )但是对于UIImageView。
I think you have to use Core Animation. 我认为您必须使用Core Animation。 If you used a CALayer
for the image view and added a mask layer to it, then used a sublayer for the view you want to appear on top of the image, it might work. 如果将CALayer
用于图像视图并向其添加了蒙版层,然后对要显示在图像顶部的视图使用了子层,则它可能会起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.