简体   繁体   中英

How to make UIView not appear on background but still appear over a UIImageView (subview)

I have a UIImageView. I also have a view. I want the view to appear on top of the UIImageView as it animates across the screen. 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.

Code: (note: isAnimating is a class property, don't worry about it)

@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. The glintImageView is the object animation across on top of it.

EDIT: I am asking for an equivalent to Shimmer ( https://github.com/facebook/Shimmer ) however for UIImageView.

I think you have to use 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM