[英]How to make UIView not appear on background but still appear over a UIImageView (subview)
我有一個UIImageView。 我也有看法。 我希望視圖在整個屏幕上設置動畫時顯示在UIImageView的頂部。 我不希望視圖出現在背景中。
我怎樣才能做到這一點?
我試圖通過添加另一個子視圖來更改子視圖的順序,但這是不可能的。
我正在考慮使用圖層而不是視圖進行動畫處理,但是UIImageView周圍具有透明部分。
代碼:(注意: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()
}
}
我的UIImageView是紀念章。 glintImageView是其上方的對象動畫。
編輯:我要求等效於Shimmer( https://github.com/facebook/Shimmer )但是對於UIImageView。
我認為您必須使用Core Animation。 如果將CALayer
用於圖像視圖並向其添加了蒙版層,然后對要顯示在圖像頂部的視圖使用了子層,則它可能會起作用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.