0

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.

CaptainCOOLGUY
  • 1,131
  • 1
  • 14
  • 26

1 Answers1

0

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.

Juri Pakaste
  • 1,402
  • 10
  • 15