Skip to content

Commit

Permalink
Merge pull request #284 from Aanabidden/master
Browse files Browse the repository at this point in the history
Add top and bottom for menu items title for circular animation
  • Loading branch information
kciter authored Feb 1, 2021
2 parents 6fab047 + 50b7d0b commit 108f3f7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class CircularAnimationViewController: UIViewController, FloatyDelegate {
// floatyCircular.openAnimationType = .semiCircular // define animation type
// floatyCircular.circleAnimationDegreeOffset = 15 // define offset in degrees

// For full circle top and bottom title
// layoutFABforFullCircleAnimation()
}

func layoutFABforQuadAnimation(floaty : Floaty) {
Expand Down Expand Up @@ -75,6 +77,37 @@ class CircularAnimationViewController: UIViewController, FloatyDelegate {
self.view.addSubview(floaty)
}

func layoutFABforFullCircleAnimation() {
let floaty = Floaty()
floaty.addDragging()
floaty.circleAnimationRadius = 100
floaty.openAnimationType = .slideUp
floaty.circleAnimationDegreeOffset = 15

floaty.buttonImage = UIImage(named: "custom-add")
floaty.hasShadow = false
floaty.paddingX = self.view.frame.width/2 - floaty.frame.width/2
floaty.paddingY = self.view.frame.height/2 - floaty.frame.height/2
floaty.fabDelegate = self

self.view.addSubview(floaty)

for index in 0...6 {
let item = FloatyItem()
item.buttonColor = .lightGray
if index.isMultiple(of: 2) {
item.title = "Map"
item.icon = UIImage(named: "icMap")

} else {
item.title = "Share"
item.icon = UIImage(named: "icShare")
}
item.titleLabelPosition = .bottom // .top
floaty.addItem(item: item)
}
}

// MARK: - Floaty Delegate Methods
func floatyWillOpen(_ floaty: Floaty) {
print("Floaty Will Open")
Expand Down
12 changes: 11 additions & 1 deletion Sources/FloatyItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import UIKit
@objc public enum FloatyItemLabelPositionType: Int {
case left
case right
case top
case bottom
}

/**
Expand Down Expand Up @@ -96,8 +98,16 @@ open class FloatyItem: UIView {
didSet {
if(titleLabelPosition == .left) {
titleLabel.frame.origin.x = -titleLabel.frame.size.width - 10
} else { //titleLabel will be on right
} else if (titleLabelPosition == .right) {
titleLabel.frame.origin.x = iconImageView.frame.origin.x + iconImageView.frame.size.width + 20
} else if (titleLabelPosition == .top) {
titleLabel.frame.origin.x = iconImageView.frame.origin.x
titleLabel.frame.origin.y = iconImageView.frame.origin.y - titleLabel.frame.size.height - 10
} else if (titleLabelPosition == .bottom) {
titleLabel.frame.origin.x = iconImageView.frame.origin.x
titleLabel.frame.origin.y = iconImageView.frame.origin.y + iconImageView.frame.size.height + 10
} else { // take default as left
titleLabel.frame.origin.x = -titleLabel.frame.size.width - 10
}
}
}
Expand Down

0 comments on commit 108f3f7

Please sign in to comment.