I currently have a UIView in Swift that has a background colour of red and a black outline with a UILabel inside.
Here is what my code looks like:
import UIKit
@IBDesignable
class AdventDoor: UIView
{
@IBInspectable var shapeColor:UIColor = UIColor.blackColor()
var width:CGFloat?
required init(coder aDecoder: NSCoder) {
//Initilse UIView
super.init(coder: aDecoder)!
//Create UILabel
let dateLabel:UILabel = UILabel(frame: CGRect(x: (bounds.width-25)-5, y: 3, width: 25, height: 20))
dateLabel.textAlignment = NSTextAlignment.Right
dateLabel.text = self.restorationIdentifier!
//Show the UILabel
self.addSubview(dateLabel)
}
override func drawRect(rect: CGRect) {
let drect = CGRect(x:0, y:0, width: bounds.width, height: bounds.height)
let bpath:UIBezierPath = UIBezierPath(rect: drect)
shapeColor.setFill()
bpath.lineWidth = 5
bpath.fill()
bpath.stroke()
}
}
Note: UIView may not show the design on the StoryBoard. To see the @IBDesignable you need to comment out the init function.
How would I animate the fill colour of the UILabel to close like sliding doors? I do not want the outline (stroke
) to change width but I do want the inside to move?
This is what I want to happen:
Currently my UIView looks like this
What I want it to look like in the end is this
And in the middle of the animation I would like it to look like this
How would I achieve such animation using Core Graphics (or any other Library if needed)