123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- //
- // Created by Tom Baranes on 25/06/16.
- // Copyright © 2016 IBAnimatable. All rights reserved.
- //
- import UIKit
- @IBDesignable
- open class AnimatableSlider: UISlider, SliderImagesDesignable, BorderDesignable, RotationDesignable, ShadowDesignable, Animatable {
- // MARK: - SliderImagesDesignable
- @IBInspectable open var thumbImage: UIImage? {
- didSet {
- configureThumbImage()
- }
- }
- @IBInspectable open var thumbHighlightedImage: UIImage? {
- didSet {
- configureThumbImage()
- }
- }
- @IBInspectable open var minimumTrackImage: UIImage? {
- didSet {
- configureMinimumTrackImage()
- }
- }
- @IBInspectable open var minimumTrackHighlightedImage: UIImage? {
- didSet {
- configureMinimumTrackImage()
- }
- }
- @IBInspectable open var maximumTrackImage: UIImage? {
- didSet {
- configureMaximumTrackImage()
- }
- }
- @IBInspectable open var maximumTrackHighlightedImage: UIImage? {
- didSet {
- configureMaximumTrackImage()
- }
- }
- // MARK: - BorderDesignable
- open var borderType: BorderType = .solid {
- didSet {
- configureBorder()
- }
- }
- @IBInspectable var _borderType: String? {
- didSet {
- borderType = BorderType(string: _borderType)
- }
- }
- @IBInspectable open var borderColor: UIColor? {
- didSet {
- configureBorder()
- }
- }
- @IBInspectable open var borderWidth: CGFloat = CGFloat.nan {
- didSet {
- configureBorder()
- }
- }
- open var borderSides: BorderSides = .AllSides {
- didSet {
- configureBorder()
- }
- }
- @IBInspectable var _borderSides: String? {
- didSet {
- borderSides = BorderSides(rawValue: _borderSides)
- }
- }
- // MARK: - RotationDesignable
- @IBInspectable open var rotate: CGFloat = CGFloat.nan {
- didSet {
- configureRotate()
- }
- }
- // MARK: - ShadowDesignable
- @IBInspectable open var shadowColor: UIColor? {
- didSet {
- configureShadowColor()
- }
- }
- @IBInspectable open var shadowRadius: CGFloat = CGFloat.nan {
- didSet {
- configureShadowRadius()
- }
- }
- @IBInspectable open var shadowOpacity: CGFloat = CGFloat.nan {
- didSet {
- configureShadowOpacity()
- }
- }
- @IBInspectable open var shadowOffset: CGPoint = CGPoint(x: CGFloat.nan, y: CGFloat.nan) {
- didSet {
- configureShadowOffset()
- }
- }
- // MARK: - Animatable
- open var animationType: AnimationType = .none
- @IBInspectable var _animationType: String? {
- didSet {
- animationType = AnimationType(string: _animationType)
- }
- }
- @IBInspectable open var autoRun: Bool = true
- @IBInspectable open var duration: Double = Double.nan
- @IBInspectable open var delay: Double = Double.nan
- @IBInspectable open var damping: CGFloat = CGFloat.nan
- @IBInspectable open var velocity: CGFloat = CGFloat.nan
- @IBInspectable open var force: CGFloat = CGFloat.nan
- @IBInspectable var _timingFunction: String = "" {
- didSet {
- timingFunction = TimingFunctionType(string: _timingFunction)
- }
- }
- open var timingFunction: TimingFunctionType = .none
- // MARK: - Lifecycle
- open override func prepareForInterfaceBuilder() {
- super.prepareForInterfaceBuilder()
- configureInspectableProperties()
- }
- open override func awakeFromNib() {
- super.awakeFromNib()
- configureInspectableProperties()
- }
- open override func layoutSubviews() {
- super.layoutSubviews()
- configureAfterLayoutSubviews()
- autoRunAnimation()
- }
- // MARK: - Private
- fileprivate func configureInspectableProperties() {
- configureAnimatableProperties()
- }
- fileprivate func configureAfterLayoutSubviews() {
- configureBorder()
- }
- }
|