Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/circular animation #278

Merged
merged 2 commits into from
Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
10DA570523F1A53E007B0F1A /* CircularAnimationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10DA570423F1A53E007B0F1A /* CircularAnimationViewController.swift */; };
801D03EC21E7110000CD67F0 /* UIView+Draggable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 801D03EB21E7110000CD67F0 /* UIView+Draggable.swift */; };
B6640EA21BCEA8DA0099510D /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = B6640EA11BCEA8DA0099510D /* LaunchScreen.xib */; };
B671D9341EB11BA5005EE7E1 /* Floaty.swift in Sources */ = {isa = PBXBuildFile; fileRef = B671D92E1EB11BA5005EE7E1 /* Floaty.swift */; };
Expand All @@ -24,6 +25,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
10DA570423F1A53E007B0F1A /* CircularAnimationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircularAnimationViewController.swift; sourceTree = "<group>"; };
801D03EB21E7110000CD67F0 /* UIView+Draggable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UIView+Draggable.swift"; path = "../../Sources/UIView+Draggable.swift"; sourceTree = "<group>"; };
B6640EA11BCEA8DA0099510D /* LaunchScreen.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LaunchScreen.xib; sourceTree = "<group>"; };
B671D92E1EB11BA5005EE7E1 /* Floaty.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Floaty.swift; path = ../../Sources/Floaty.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -77,6 +79,7 @@
B6F66E191BC1017F00E47769 /* AppDelegate.swift */,
B6F66E1B1BC1017F00E47769 /* ViewController.swift */,
B6CC36171D91CBFB00D04C6C /* TableViewController.swift */,
10DA570423F1A53E007B0F1A /* CircularAnimationViewController.swift */,
B6F66E1D1BC1017F00E47769 /* Main.storyboard */,
B6F66E201BC1017F00E47769 /* Assets.xcassets */,
B675871D1BCCFEBC00C4BEAF /* Icons.xcassets */,
Expand Down Expand Up @@ -182,6 +185,7 @@
B671D9381EB11BA5005EE7E1 /* FloatyViewController.swift in Sources */,
B671D9371EB11BA5005EE7E1 /* FloatyManager.swift in Sources */,
B6CC36181D91CBFB00D04C6C /* TableViewController.swift in Sources */,
10DA570523F1A53E007B0F1A /* CircularAnimationViewController.swift in Sources */,
B671D9351EB11BA5005EE7E1 /* FloatyDelegate.swift in Sources */,
B671D9361EB11BA5005EE7E1 /* FloatyItem.swift in Sources */,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
Expand Down Expand Up @@ -29,6 +39,11 @@
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
Expand Down
49 changes: 41 additions & 8 deletions Sample/KCFloatingActionButton/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="15G1004" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Circular Animation View Controller-->
<scene sceneID="YRb-h8-opr">
<objects>
<viewController id="5FN-Ty-bmH" customClass="CircularAnimationViewController" customModule="KCFloatingActionButton_Sample" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="jRE-Bq-hjW"/>
<viewControllerLayoutGuide type="bottom" id="7S9-nB-zZS"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Wxk-4H-Wh4">
<rect key="frame" x="0.0" y="0.0" width="414" height="842"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="c4J-Hb-DVx" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1638" y="-323"/>
</scene>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
Expand All @@ -15,33 +34,44 @@
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC" customClass="UIControl">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fPA-BB-5Md">
<rect key="frame" x="186.5" y="431" width="41" height="34"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<state key="normal" title="Push"/>
<connections>
<segue destination="1zs-w2-pP5" kind="presentation" identifier="next" modalTransitionStyle="coverVertical" id="2S9-T2-Pp4"/>
</connections>
</button>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Keyboard Test" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="EtJ-sz-GUf">
<rect key="frame" x="147" y="475" width="120" height="34"/>
<constraints>
<constraint firstAttribute="width" constant="120" id="1bR-ia-1Mv"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="NxG-bO-oUz">
<rect key="frame" x="248.5" y="366.5" width="51" height="31"/>
<connections>
<action selector="customImageSwitched:" destination="BYZ-38-t0r" eventType="valueChanged" id="W9c-wW-hzF"/>
</connections>
</switch>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Custom image" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6wk-tB-Wom">
<rect key="frame" x="117" y="371.5" width="110.5" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="sb7-Rv-vY9">
<rect key="frame" x="131" y="140" width="152" height="30"/>
<state key="normal" title="Try Circular Animation"/>
<connections>
<segue destination="5FN-Ty-bmH" kind="presentation" modalTransitionStyle="coverVertical" id="K8o-Xk-emT"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="0.19607843137254902" green="0.19607843137254902" blue="0.19607843137254902" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
Expand All @@ -51,8 +81,10 @@
<constraint firstItem="fPA-BB-5Md" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="HFT-Qi-ewT"/>
<constraint firstItem="NxG-bO-oUz" firstAttribute="centerY" secondItem="6wk-tB-Wom" secondAttribute="centerY" id="Iyc-Qn-P0y"/>
<constraint firstItem="fPA-BB-5Md" firstAttribute="top" secondItem="6wk-tB-Wom" secondAttribute="bottom" constant="39" id="JrH-9q-Vm3"/>
<constraint firstItem="sb7-Rv-vY9" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" constant="96" id="Qcq-uI-Tnu"/>
<constraint firstItem="EtJ-sz-GUf" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="bf2-mE-Mwh"/>
<constraint firstItem="NxG-bO-oUz" firstAttribute="leading" secondItem="6wk-tB-Wom" secondAttribute="trailing" constant="21" id="fcZ-Ez-bOP"/>
<constraint firstItem="sb7-Rv-vY9" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="rd7-DR-M62"/>
</constraints>
<connections>
<action selector="endEditing" destination="dkx-z0-nzr" eventType="touchUpInside" id="OCh-jJ-hRJ"/>
Expand All @@ -73,7 +105,7 @@
<toolbarItems/>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" translucent="NO" prompted="NO"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" translucent="NO" id="goD-3X-fAG">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="56"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
Expand All @@ -90,18 +122,19 @@
<objects>
<tableViewController id="ifI-oW-xs8" customClass="TableViewController" customModule="KCFloatingActionButton_Sample" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="hsb-tl-5pz">
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="786"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="TestCell" id="pDY-n3-rcQ">
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
<rect key="frame" x="0.0" y="28" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="pDY-n3-rcQ" id="JpO-zE-skO">
<frame key="frameInset" width="375" height="43"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iB9-kx-XrG">
<rect key="frame" x="186" y="12" width="42" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
//
// CircularAnimationViewController.swift
// KCFloatingActionButton-Sample
//
// Created by MBP on 10/02/2020.
// Copyright © 2020 kciter. All rights reserved.
//

import UIKit

class CircularAnimationViewController: UIViewController, FloatyDelegate {

var floatyQuad = Floaty()
var floatyCircular = Floaty()

override func viewDidLoad() {
super.viewDidLoad()

// For QuadCircularAnimaition
layoutFABforQuadAnimation(floaty: floatyQuad)
floatyQuad.addDragging()
floatyQuad.openAnimationType = .quadCircular // define animation type
floatyQuad.circleAnimationDegreeOffset = 10 // define offset in degrees
floatyQuad.circleAnimationRadius = 120 // by default is 150

// For SemiCirularAnimation uncomment this code and comment the QuadCircularAnimaition code. Only one floaty button will work at a time
// layoutFABforSemiCircleAnimation(floaty: floatyCircular)
// floatyCircular.addDragging()
// floatyCircular.openAnimationType = .semiCircular // define animation type
// floatyCircular.circleAnimationDegreeOffset = 15 // define offset in degrees

}

func layoutFABforQuadAnimation(floaty : Floaty) {
floaty.hasShadow = false
floaty.paddingX = floaty.frame.width
floaty.fabDelegate = self

let item = FloatyItem()
item.buttonColor = UIColor.blue

floaty.addItem("", icon: UIImage(named: "icShare"))
floaty.addItem("", icon: UIImage(named: "icMap")) { item in
let alert = UIAlertController(title: "Hey", message: "I'm hungry...", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Me too", style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
floaty.addItem(item: item)

self.view.addSubview(floaty)
}

func layoutFABforSemiCircleAnimation(floaty : Floaty) {
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

let item = FloatyItem()
item.buttonColor = UIColor.blue

floaty.addItem("", icon: UIImage(named: "icShare"))
floaty.addItem("", icon: UIImage(named: "icMap")) { item in
let alert = UIAlertController(title: "Hey", message: "I'm hungry...", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Me too", style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
floaty.addItem(item: item)
floaty.addItem("", icon: UIImage(named: "icShare"))
floaty.addItem("", icon: UIImage(named: "icMap"))
floaty.addItem("", icon: UIImage(named: "icShare"))
floaty.addItem("", icon: UIImage(named: "icMap"))

self.view.addSubview(floaty)
}

// MARK: - Floaty Delegate Methods
func floatyWillOpen(_ floaty: Floaty) {
print("Floaty Will Open")
}

func floatyDidOpen(_ floaty: Floaty) {
print("Floaty Did Open")
}

func floatyWillClose(_ floaty: Floaty) {
print("Floaty Will Close")
}

func floatyDidClose(_ floaty: Floaty) {
print("Floaty Did Close")
}

}
Loading