Skip to content

Commit

Permalink
Merge pull request #16 from ykyouhei/feature/swift3.1
Browse files Browse the repository at this point in the history
Feature/swift3.1
  • Loading branch information
ykyouhei authored Apr 2, 2017
2 parents 49d8408 + e298601 commit a9a4f9e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
3.1
17 changes: 14 additions & 3 deletions Example/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="1zI-So-CCp">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12118" systemVersion="16C67" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="1zI-So-CCp">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12086"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand All @@ -19,6 +22,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view tag="3" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ptD-fV-BOO" customClass="KYShutterButton" customModule="KYShutterButton">
<rect key="frame" x="94.5" y="374.5" width="66" height="66"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="66" id="ERC-xB-Viu"/>
Expand All @@ -37,6 +41,7 @@
</connections>
</view>
<view tag="2" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Vbb-QT-tAI" customClass="KYShutterButton" customModule="KYShutterButton">
<rect key="frame" x="214.5" y="226.5" width="66" height="66"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="66" id="6rY-DD-cVE"/>
Expand All @@ -55,6 +60,7 @@
</connections>
</view>
<view tag="3" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="aLP-je-VrZ" customClass="KYShutterButton" customModule="KYShutterButton">
<rect key="frame" x="214.5" y="374.5" width="66" height="66"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="66" id="Xc4-BE-Thk"/>
Expand All @@ -76,6 +82,7 @@
</connections>
</view>
<view tag="1" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="v1X-Iv-Kcs" customClass="KYShutterButton" customModule="KYShutterButton">
<rect key="frame" x="94.5" y="226.5" width="66" height="66"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="66" id="1nr-Kg-YBL"/>
Expand All @@ -91,6 +98,7 @@
</userDefinedRuntimeAttributes>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Normal" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sJU-SA-GY2">
<rect key="frame" x="99.5" y="201" width="56" height="20.5"/>
<constraints>
<constraint firstAttribute="width" constant="56" id="PgG-H7-oNA"/>
</constraints>
Expand All @@ -99,16 +107,19 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="SlowMotion" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Fva-pz-owc">
<rect key="frame" x="82" y="346" width="91" height="20.5"/>
<fontDescription key="fontDescription" type="system" weight="light" pointSize="17"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Normal" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="GLI-ZD-Cdd">
<rect key="frame" x="219.5" y="201" width="56" height="20.5"/>
<fontDescription key="fontDescription" type="system" weight="light" pointSize="17"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="TimeLapse" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aBT-ji-BYE">
<rect key="frame" x="205" y="346" width="85" height="20.5"/>
<constraints>
<constraint firstAttribute="width" constant="85" id="gM8-zq-vZ4"/>
</constraints>
Expand Down
2 changes: 1 addition & 1 deletion KYShutterButton.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "KYShutterButton"
s.version = "2.0.0"
s.version = "2.0.1"
s.summary = "KYShutterButton is a custom button that is similar to the shutter button of the camera app"
s.homepage = "https://github.com/ykyouhei/KYShutterButton"
s.license = "MIT"
Expand Down
22 changes: 11 additions & 11 deletions KYShutterButton/Classes/KYShutterButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ open class KYShutterButton: UIButton {
return UIBezierPath(
arcCenter: CGPoint(x: self.bounds.midX, y: self.bounds.midY),
radius: self.bounds.width/2 - self._arcWidth/2,
startAngle: -CGFloat(M_PI_2),
endAngle: CGFloat(M_PI*2.0) - CGFloat(M_PI_2),
startAngle: -.pi/2,
endAngle: .pi*2 - .pi/2,
clockwise: true
)
}
Expand Down Expand Up @@ -212,7 +212,7 @@ open class KYShutterButton: UIButton {
private var _startRotateAnimation: CABasicAnimation {
let animation = CABasicAnimation(keyPath: "transform.rotation.z")
animation.fromValue = 0
animation.toValue = CGFloat(M_PI*2.0)
animation.toValue = CGFloat.pi*2
animation.duration = _kstartAnimateDuration
return animation
}
Expand Down Expand Up @@ -240,7 +240,7 @@ open class KYShutterButton: UIButton {
private var _recordingRotateAnimation: CABasicAnimation {
let animation = CABasicAnimation(keyPath: "transform.rotation")
animation.fromValue = 0
animation.toValue = CGFloat(M_PI*2.0)
animation.toValue = CGFloat.pi*2
animation.duration = TimeInterval(rotateAnimateDuration)
animation.repeatCount = Float.infinity
animation.beginTime = CACurrentMediaTime() + _kstartAnimateDuration
Expand Down Expand Up @@ -334,13 +334,13 @@ open class KYShutterButton: UIButton {
}

private func p_arcPathWithProgress(_ progress: CGFloat, clockwise: Bool = true) -> UIBezierPath {
let diameter = 2*CGFloat(M_PI)*(self.bounds.width/2 - self._arcWidth/3)
let diameter = 2*CGFloat.pi*(self.bounds.width/2 - self._arcWidth/3)
let startAngle = clockwise ?
-CGFloat(M_PI_2) :
-CGFloat(M_PI_2) + CGFloat(M_PI)*(540/diameter)/180
-CGFloat.pi/2 :
-CGFloat.pi/2 + CGFloat.pi*(540/diameter)/180
let endAngle = clockwise ?
CGFloat(M_PI*2.0)*progress - CGFloat(M_PI_2) :
CGFloat(M_PI*2.0)*progress - CGFloat(M_PI_2) + CGFloat(M_PI)*(540/diameter)/180
CGFloat.pi*2*progress - CGFloat.pi/2 :
CGFloat.pi*2*progress - CGFloat.pi/2 + CGFloat.pi*(540/diameter)/180
let path = UIBezierPath(
arcCenter: CGPoint(x: self.bounds.midX, y: self.bounds.midY),
radius: self.bounds.width/2 - self._arcWidth/3,
Expand All @@ -360,8 +360,8 @@ open class KYShutterButton: UIButton {
_arcLayer.lineDashPattern = [1, 1]
_progressLayer.isHidden = true
case .timeLapse:
let diameter = CGFloat(M_PI)*(self.bounds.width/2 - self._arcWidth/2)
let progressDiameter = 2*CGFloat(M_PI)*(self.bounds.width/2 - self._arcWidth/3)
let diameter = CGFloat.pi*(self.bounds.width/2 - self._arcWidth/2)
let progressDiameter = 2*CGFloat.pi*(self.bounds.width/2 - self._arcWidth/3)

_arcLayer.lineDashPattern = [1, NSNumber(value: (diameter/10 - 1).native)]
_progressLayer.lineDashPattern = [1, NSNumber(value: (progressDiameter/60 - 1).native)]
Expand Down
2 changes: 1 addition & 1 deletion KYShutterButton/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.0.0</string>
<string>2.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Pod Version](http://img.shields.io/cocoapods/v/KYShutterButton.svg?style=flat)](http://cocoadocs.org/docsets/KYShutterButton/)
[![Pod Platform](http://img.shields.io/cocoapods/p/KYShutterButton.svg?style=flat)](http://cocoadocs.org/docsets/KYShutterButton/)
[![Pod License](http://img.shields.io/cocoapods/l/KYShutterButton.svg?style=flat)](https://github.com/ykyohei/KYShutterButton/blob/master/LICENSE)
![Swift version](https://img.shields.io/badge/swift-3.0-orange.svg)
![Swift version](https://img.shields.io/badge/swift-3.1-orange.svg)


`KYShutterButton` is a custom button that is similar to the shutter button of the camera app
Expand Down

0 comments on commit a9a4f9e

Please sign in to comment.