FloatingImageViewStack is a simple custom control to let you layer floating images on top of eachother. Tap into any image in the stack to select the image and bring it into focus. Make sure to take a look at the example project included.
FloatingImageViewStack is IBDesignable
and many of the properties can be easily changed in the attributes inspect inside of interface builder. Listed below are all of the properties with default values that can be changed via Interface Builder.
@IBInspectable var verticalSpacing : CGFloat = 35
@IBInspectable var borderColor : UIColor = UIColor.clear
@IBInspectable var topBorderColor : UIColor = UIColor.black
@IBInspectable var topColor : UIColor = UIColor.clear
@IBInspectable var topOpacity : Float = 1.0
@IBInspectable var angle : CGFloat = -45
@IBInspectable var color : UIColor = UIColor.clear
@IBInspectable var selectedBorderWidth : CGFloat = 3.0
@IBInspectable var animationDuration : CGFloat = 0.7
Drag a view onto your view controller and subclass it as FloatingImageViewStack
in interface builder.
Configure any properties via the attribute inspector.
Assign the FloatingImageViewContainerDelegate
to receive user interactions.
class ViewController: UIViewController {
@IBOutlet weak var floatingImageStack: FloatingImageViewStack!
override func viewDidLoad() {
super.viewDidLoad()
floatingImageStack.delegate = self
}
}
extension ViewController : FloatingImageViewContainerDelegate {
func didSelectFloatingTop() {
}
func didSelectFloatingImage(selectedView: FloatingImageView) {
}
}
Finally, then simply add an image onto the stack.
floatingImageStack.addImageToStack(imageToAdd: UIImage(named: "sample_image")!)
Remove images from the stack by index.
floatingImageStack.removeFloatingView(at: 0)
Remove images from the stack directly.
func didSelectFloatingImage(selectedView: FloatingImageView) {
floatingImageStack.removeSelectedFloatingView(viewToRemove: selectedView)
}