Compare commits

...

4 Commits

Author SHA1 Message Date
Alex K c520680100 Fixes #20 2018-01-22 16:34:47 +03:00
Alex K 04e27502df update podspec 2018-01-22 12:59:35 +03:00
Alex K 9f211f33af Fixes #43 2018-01-22 12:57:32 +03:00
Alex K 083d952ad7 increase pod version 2018-01-18 15:03:49 +03:00
2 changed files with 40 additions and 11 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'CircleMenu'
s.version = '3.0.1'
s.version = '3.0.3'
s.summary = 'Amazing animation with buttons'
s.homepage = 'https://github.com/Ramotion/circle-menu'
s.license = 'MIT'
+39 -10
View File
@@ -88,6 +88,16 @@ open class CircleMenu: UIButton {
@IBInspectable open var distance: Float = 100
/// Delay between show buttons
@IBInspectable open var showDelay: Double = 0
// Pop buttons radius, if nil use center button size
open var subButtonsRadius: CGFloat?
// Show buttons event
open var showButtonsEvent: UIControlEvents = UIControlEvents.touchUpInside {
didSet {
addActions(newEvent: showButtonsEvent, oldEvent: oldValue)
}
}
/// The object that acts as the delegate of the circle menu.
@IBOutlet open var delegate: AnyObject? // CircleMenuDelegate?
@@ -140,7 +150,7 @@ open class CircleMenu: UIButton {
}
fileprivate func commonInit() {
addActions()
addActions(newEvent: showButtonsEvent)
customNormalIconView = addCustomImageView(state: UIControlState())
@@ -167,7 +177,7 @@ open class CircleMenu: UIButton {
buttonsAnimationIsShow(isShow: false, duration: duration, hideDelay: hideDelay)
tapBounceAnimation()
tapBounceAnimation(duration: 0.5)
tapRotatedAnimation(0.3, isSelected: false)
}
@@ -202,7 +212,13 @@ open class CircleMenu: UIButton {
let angle: Float = Float(index) * step
let distance = Float(bounds.size.height / 2.0)
let button = Init(CircleMenuButton(size: bounds.size, platform: platform, distance: distance, angle: angle)) {
let buttonSize: CGSize
if let subButtonsRadius = self.subButtonsRadius {
buttonSize = CGSize(width: subButtonsRadius * 2, height: subButtonsRadius * 2)
} else {
buttonSize = bounds.size
}
let button = Init(CircleMenuButton(size: buttonSize, platform: platform, distance: distance, angle: angle)) {
$0.tag = index
$0.addTarget(self, action: #selector(CircleMenu.buttonHandler(_:)), for: UIControlEvents.touchUpInside)
$0.alpha = 0
@@ -275,13 +291,19 @@ open class CircleMenu: UIButton {
// MARK: configure
fileprivate func addActions() {
addTarget(self, action: #selector(CircleMenu.onTap), for: UIControlEvents.touchUpInside)
fileprivate func addActions(newEvent: UIControlEvents, oldEvent: UIControlEvents? = nil) {
if let oldEvent = oldEvent { removeTarget(self, action: #selector(CircleMenu.onTap), for: oldEvent) }
addTarget(self, action: #selector(CircleMenu.onTap), for: newEvent)
}
// MARK: actions
private var isBounceAnimating: Bool = false
@objc func onTap() {
guard isBounceAnimating == false else { return }
isBounceAnimating = true
if buttonsIsShown() == false {
let platform = createPlatform()
buttons = createButtons(platform: platform)
@@ -291,7 +313,7 @@ open class CircleMenu: UIButton {
let duration = isShow ? 0.5 : 0.2
buttonsAnimationIsShow(isShow: isShow, duration: duration)
tapBounceAnimation()
tapBounceAnimation(duration: 0.5) { [weak self] _ in self?.isBounceAnimating = false }
tapRotatedAnimation(0.3, isSelected: isShow)
}
@@ -299,9 +321,16 @@ open class CircleMenu: UIButton {
guard let platform = self.platform else { return }
delegate?.circleMenu?(self, buttonWillSelected: sender, atIndex: sender.tag)
let strokeWidth: CGFloat
if let radius = self.subButtonsRadius {
strokeWidth = radius * 2
} else {
strokeWidth = bounds.size.height
}
let circle = CircleMenuLoader(radius: CGFloat(distance),
strokeWidth: bounds.size.height,
strokeWidth: strokeWidth,
platform: platform,
color: sender.backgroundColor)
@@ -359,14 +388,14 @@ open class CircleMenu: UIButton {
}
}
fileprivate func tapBounceAnimation() {
fileprivate func tapBounceAnimation(duration: TimeInterval, completion: ((Bool)->())? = nil) {
transform = CGAffineTransform(scaleX: 0.9, y: 0.9)
UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 0.3, initialSpringVelocity: 5,
UIView.animate(withDuration: duration, delay: 0, usingSpringWithDamping: 0.3, initialSpringVelocity: 5,
options: UIViewAnimationOptions.curveLinear,
animations: { () -> Void in
self.transform = CGAffineTransform(scaleX: 1, y: 1)
},
completion: nil)
completion: completion)
}
fileprivate func tapRotatedAnimation(_ duration: Float, isSelected: Bool) {