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

update to use swift5 #6

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
1 change: 0 additions & 1 deletion .swift-version

This file was deleted.

2 changes: 1 addition & 1 deletion Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

return true
Expand Down
45 changes: 30 additions & 15 deletions Example/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,52 @@
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
15 changes: 0 additions & 15 deletions KYWheelTabController.podspec

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ open class KYWheelTabController: UITabBarController {
// MARK: Properties
/* ====================================================================== */

@IBInspectable open var tintColor: UIColor = UIColor(colorLiteralRed: 0, green: 122/255, blue: 1, alpha: 1) {
@IBInspectable open var tintColor: UIColor = UIColor(red: 0, green: 122/255, blue: 1, alpha: 1) {
didSet {
wheelMenuView.tintColor = tintColor
}
Expand Down Expand Up @@ -50,6 +50,8 @@ open class KYWheelTabController: UITabBarController {
wheelMenuView.delegate = self
wheelMenuView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(wheelMenuView)
let window = UIApplication.shared.windows[0]
let safeFrame = window.safeAreaLayoutGuide.layoutFrame

view.addConstraints([
NSLayoutConstraint(
Expand Down Expand Up @@ -86,7 +88,7 @@ open class KYWheelTabController: UITabBarController {
toItem: view,
attribute: .bottom,
multiplier: 1.0,
constant: 44
constant: 34 - safeFrame.minY
)
])
}
Expand Down
5 changes: 2 additions & 3 deletions KYWheelTabController/Classes/Views/MenuLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ internal class MenuLayer: CAShapeLayer {
/* ===================================================================== */

let tabBarItem: UITabBarItem

var tintColor: UIColor = UIColor(colorLiteralRed: 0, green: 122/255, blue: 1, alpha: 1) {
var tintColor = UIColor(red: 0, green: 122/255, blue: 1, alpha: 1) {
didSet {
updateContents()
}
Expand Down Expand Up @@ -66,7 +65,7 @@ internal class MenuLayer: CAShapeLayer {

contentsLayer = CALayer()
contentsLayer.frame = bounds
contentsLayer.contentsGravity = kCAGravityCenter
contentsLayer.contentsGravity = CALayerContentsGravity.center
contentsLayer.contentsScale = scale
contentsLayer.transform = contentsTransform
contentsLayer.rasterizationScale = scale
Expand Down
24 changes: 12 additions & 12 deletions KYWheelTabController/Classes/Views/WheelMenuView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ public protocol WheelMenuViewDelegate: NSObjectProtocol {
} set {
menuLayers.forEach{ $0.removeFromSuperlayer() }

let angle = 2 * CGFloat(M_PI) / CGFloat(newValue.count)
let angle = 2 * CGFloat(Double.pi) / CGFloat(newValue.count)

menuLayers = newValue.enumerated().map {
let startAngle = CGFloat($0.offset) * angle - angle / 2 - CGFloat(M_PI_2)
let endAngle = CGFloat($0.offset + 1) * angle - angle / 2 - CGFloat(M_PI_2) - 0.005
let startAngle = CGFloat($0.offset) * angle - angle / 2 - CGFloat(Double.pi)
let endAngle = CGFloat($0.offset + 1) * angle - angle / 2 - CGFloat(Double.pi) - 0.005
let center = CGPoint(
x: bounds.width/2,
y: bounds.height/2)

var transform = CATransform3DMakeRotation(angle * CGFloat($0.offset), 0, 0, 1)
var transform = CATransform3DMakeRotation(CGFloat(angle) * CGFloat($0.offset), 0, 0, 1)
transform = CATransform3DTranslate(
transform,
0,
Expand Down Expand Up @@ -98,7 +98,7 @@ public protocol WheelMenuViewDelegate: NSObjectProtocol {
fileprivate var startPoint = CGPoint.zero

fileprivate var currentAngle: CGFloat {
let angle = 2 * CGFloat(M_PI) / CGFloat(menuLayers.count)
let angle = 2 * CGFloat(Double.pi) / CGFloat(menuLayers.count)
return CGFloat(menuLayers.count - selectedIndex) * angle
}

Expand All @@ -120,7 +120,7 @@ public protocol WheelMenuViewDelegate: NSObjectProtocol {
let bundle = Bundle(for: type(of: self))
let image = centerButtonCustomImage ?? UIImage(named: "Menu", in: bundle, compatibleWith: nil)!
.withRenderingMode(.alwaysTemplate)
centerButton.setImage(image, for: UIControlState())
centerButton.setImage(image, for: UIControl.State())
centerButton.layer.shadowOpacity = 0.3
centerButton.layer.shadowRadius = 10
centerButton.layer.shadowOffset = CGSize.zero
Expand Down Expand Up @@ -162,11 +162,11 @@ public protocol WheelMenuViewDelegate: NSObjectProtocol {

view.translatesAutoresizingMaskIntoConstraints = false
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[view]-0-|",
options:NSLayoutFormatOptions(rawValue: 0),
options:NSLayoutConstraint.FormatOptions(rawValue: 0),
metrics:nil,
views: viewDictionary))
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[view]-0-|",
options:NSLayoutFormatOptions(rawValue: 0),
options:NSLayoutConstraint.FormatOptions(rawValue: 0),
metrics:nil,
views: viewDictionary))

Expand Down Expand Up @@ -209,14 +209,14 @@ public protocol WheelMenuViewDelegate: NSObjectProtocol {
startPoint = location

default:
let angle = 2 * CGFloat(M_PI) / CGFloat(menuLayers.count)
let angle = 2 * CGFloat(Double.pi) / CGFloat(menuLayers.count)
var menuViewAngle = atan2(menuBaseView.transform.b, menuBaseView.transform.a)

if menuViewAngle < 0 {
menuViewAngle += CGFloat(2 * M_PI)
menuViewAngle += 2 * CGFloat(Double.pi)
}

var index = menuLayers.count - Int((menuViewAngle + CGFloat(M_PI_4)) / angle)
var index = menuLayers.count - Int((menuViewAngle + CGFloat(Double.pi)/4) / angle)
if index == menuLayers.count {
index = 0
}
Expand Down Expand Up @@ -292,7 +292,7 @@ public protocol WheelMenuViewDelegate: NSObjectProtocol {
let bundle = Bundle(for: type(of: self))
let image = centerButtonCustomImage ?? UIImage(named: "Menu", in: bundle, compatibleWith: nil)!
.withRenderingMode(.alwaysTemplate)
centerButton.setImage(image, for: UIControlState())
centerButton.setImage(image, for: UIControl.State())
}

public func openMenuView() {
Expand Down
2 changes: 1 addition & 1 deletion KYWheelTabController/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>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
15 changes: 15 additions & 0 deletions WheelTabController.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Pod::Spec.new do |s|
s.name = "WheelTabController"
s.version = "2.1.1"
s.summary = "KYWheelTabController is a subclass of UITabBarController.It displays the circular menu instead of UITabBar."
s.homepage = "https://github.com/yaron3/KYWheelTabController"
s.license = "MIT"
s.author = { "Yaron Jackoby" => "[email protected]" }
s.platform = :ios
s.source = { :git => "https://github.com/yaron3/KYWheelTabController.git", :tag => s.version.to_s }
s.source_files = "KYWheelTabController/Classes/**/*.swift"
s.resources = "KYWheelTabController/Resources/*"
s.requires_arc = true
s.ios.deployment_target = '11.0'
s.swift_versions = '5.0'
end
Loading