Created
December 13, 2018 08:11
-
-
Save freele/6a3228fc672a514d05a51e4e66c95846 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SLRMenuButtonView.swift | |
// StreamLayer iOS | |
// | |
// Created by Alexander Kremenets on 12/12/2018. | |
// Copyright © 2018 StreamLayer, Inc. All rights reserved. | |
// | |
import Foundation | |
import UIKit | |
class SLRMenuButtonView: UIView { | |
init(tappableImage: SLRImageView) { | |
self.tappableImage = tappableImage | |
super.init(frame: tappableImage.frame) | |
loadSubviews() | |
initAnimators() | |
activateAnimations() | |
} | |
// MARK: Subviews | |
public var tappableImage: SLRImageView! = nil | |
private let tooltipButtonBackgroundEffect: UIView = { | |
let tooltipButtonBackgroundEffect = UIView() | |
tooltipButtonBackgroundEffect.backgroundColor = UIColor.red | |
tooltipButtonBackgroundEffect.borderColor = UIColor.white | |
tooltipButtonBackgroundEffect.clipsToBounds = true | |
tooltipButtonBackgroundEffect.layer.cornerRadius = 5 | |
return tooltipButtonBackgroundEffect | |
}() | |
private var scaleChange1: UIViewPropertyAnimator! = nil | |
private var scaleChange2: UIViewPropertyAnimator! = nil | |
private func activateAnimations() { | |
self.scaleChange1.startAnimation() | |
// UIView.animate(withDuration: 1, delay: 0.25, options: UIView.AnimationOptions.curveEaseOut, animations: { | |
// self.tooltipButtonBackgroundEffect.backgroundColor = .orange | |
// self.tooltipButtonBackgroundEffect.transform = CGAffineTransform(scaleX: 1.25, y: 1.25) | |
// | |
// }, completion: nil) | |
} | |
private func initAnimators() { | |
self.scaleChange1 = UIViewPropertyAnimator( | |
duration: 1.5, | |
curve: .easeIn, | |
animations: { [weak self] in | |
self?.tooltipButtonBackgroundEffect.transform = CGAffineTransform(scaleX: 1.25, y: 1.25) | |
}) | |
// scaleChange1.pausesOnCompletion = false | |
scaleChange1.addCompletion({_ in | |
self.scaleChange1.fractionComplete = 0.5 | |
// self.scaleChange1.startAnimation() | |
}) | |
} | |
private func loadSubviews() { | |
tooltipButtonBackgroundEffect.frame = self.bounds | |
self.addSubview(tooltipButtonBackgroundEffect) | |
self.addSubview(tappableImage) | |
} | |
required init?(coder aDecoder: NSCoder) { | |
super.init(coder: aDecoder) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment