This file contains hidden or 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
switch progress { | |
case AnimationState.full.rawValue...: | |
let newProgress = (progress - AnimationState.full.rawValue) / (AnimationState.finalBigSize.rawValue - AnimationState.full.rawValue) | |
let scale = 1 + (maxScale-1) * newProgress | |
foregroundButton.transform = CGAffineTransform(scaleX: scale, y: scale) | |
case ...AnimationState.full.rawValue: | |
foregroundButton.transform = .identity | |
default: | |
print("surprise") |
This file contains hidden or 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
func update(progress: CGFloat) { | |
let shiftedProgress = (progress - AnimationState.start.rawValue) / (AnimationState.full.rawValue - AnimationState.start.rawValue) | |
let height: CGFloat = foregroundButton.bounds.height * shiftedProgress | |
let rect = CGRect(x: 0, y: foregroundButton.bounds.height - height, width: foregroundButton.bounds.width, height: height) | |
let path = UIBezierPath(rect: rect).cgPath | |
shapeLayer.path = path | |
} |
This file contains hidden or 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
// ... | |
func setup() { | |
// ... | |
layout: do { | |
addSubview(backgroundButton) |
This file contains hidden or 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
class SearchView: UIView { | |
// MARK: Properties | |
// ... | |
struct Colors { | |
static let backgroundButtonBackgroundColor = UIColor.clear | |
static let backgroundButtonTintColor = #colorLiteral(red: 0.6000000238, green: 0.6000000238, blue: 0.6000000238, alpha: 1) | |
static let foregroundButtonBackgroundColor = #colorLiteral(red: 1, green: 0.8, blue: 0, alpha: 1) |
This file contains hidden or 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
class SearchView: UIView { | |
// MARK: Properties | |
... | |
// MARK: Setup | |
func setup() { | |
This file contains hidden or 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
class SearchView: UIView { | |
// MARK: Properties | |
... | |
struct Colors { | |
static let backgroundButtonBackgroundColor = UIColor.clear | |
static let backgroundButtonTintColor = #colorLiteral(red: 0.6000000238, green: 0.6000000238, blue: 0.6000000238, alpha: 1) | |
static let foregroundButtonBackgroundColor = #colorLiteral(red: 1, green: 0.8, blue: 0, alpha: 1) |
This file contains hidden or 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
// We replace | |
let rect = CGRect(x: 0, y: 0, width: foregroundButton.bounds.width, height: height) | |
// by | |
let rect = CGRect(x: 0, y: foregroundButton.bounds.height - height, width: foregroundButton.bounds.width, height: height) |
This file contains hidden or 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
func update(progress: CGFloat) { | |
let height: CGFloat = foregroundButton.bounds.height * progress | |
let rect = CGRect(x: 0, y: 0, width: foregroundButton.bounds.width, height: height) | |
let path = UIBezierPath(rect: rect).cgPath | |
shapeLayer.path = path | |
} |
This file contains hidden or 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
class SearchView: UIView { | |
// MARK: Properties | |
enum AnimationState: CGFloat { | |
case start = 0.0, full = 0.7, finalBigSize = 1 | |
} | |
} |