Skip to content

Commit

Permalink
Bump to version 1.1.0
Browse files Browse the repository at this point in the history
Remove middle button from tab bar due to outside touch not being recognized
Update example to include a "real" middle button that supports full touch
Make `commonInit` open function
  • Loading branch information
Adrian Mateoaea committed Feb 6, 2017
1 parent 45439ea commit 52f3ab9
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 25 deletions.
2 changes: 1 addition & 1 deletion FlexTabBar.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "FlexTabBar"
s.version = "1.0.2"
s.version = "1.1.0"
s.summary = "Flexible Tab Bar for Swift"
s.homepage = "https://github.com/wonderkiln/FlexTabBar"
s.license = { :type => "MIT", :file => "LICENSE" }
Expand Down
4 changes: 4 additions & 0 deletions WKTabBarController-Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
3A3363301E48981700711F39 /* FlexTabBar.podspec in Resources */ = {isa = PBXBuildFile; fileRef = 3A33632F1E48981700711F39 /* FlexTabBar.podspec */; };
3A5FD9181D9BD5160061CC9C /* WKTabBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A5FD9171D9BD5160061CC9C /* WKTabBarItem.swift */; };
3A5FD91A1D9BD5270061CC9C /* WKTabBarControllerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A5FD9191D9BD5270061CC9C /* WKTabBarControllerProtocol.swift */; };
3A5FD91C1D9BD5380061CC9C /* WKBaseTabBarCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A5FD91B1D9BD5380061CC9C /* WKBaseTabBarCell.swift */; };
Expand Down Expand Up @@ -47,6 +48,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
3A33632F1E48981700711F39 /* FlexTabBar.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FlexTabBar.podspec; sourceTree = SOURCE_ROOT; };
3A5FD9171D9BD5160061CC9C /* WKTabBarItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WKTabBarItem.swift; sourceTree = "<group>"; };
3A5FD9191D9BD5270061CC9C /* WKTabBarControllerProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WKTabBarControllerProtocol.swift; sourceTree = "<group>"; };
3A5FD91B1D9BD5380061CC9C /* WKBaseTabBarCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WKBaseTabBarCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -117,6 +119,7 @@
3A94D9231D828BB90064FE20 /* WKTabBarController */ = {
isa = PBXGroup;
children = (
3A33632F1E48981700711F39 /* FlexTabBar.podspec */,
3A5FD91B1D9BD5380061CC9C /* WKBaseTabBarCell.swift */,
3A94D92F1D828C020064FE20 /* WKTabBarController.swift */,
3A5FD9191D9BD5270061CC9C /* WKTabBarControllerProtocol.swift */,
Expand Down Expand Up @@ -232,6 +235,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3A3363301E48981700711F39 /* FlexTabBar.podspec in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
67 changes: 44 additions & 23 deletions WKTabBarController-Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class ViewController: WKTabBarController {
tabBarItems = [
WKTabBarItem(title: "Home", image: #imageLiteral(resourceName: "ic_item"), selected: #imageLiteral(resourceName: "ic_item_sel")),
WKTabBarItem(title: "Activity", image: #imageLiteral(resourceName: "ic_item"), selected: #imageLiteral(resourceName: "ic_item_sel")),
WKTabBarItem(title: "Add Procedure", image: #imageLiteral(resourceName: "ic_middle")),
WKTabBarItem(title: "Add Procedure", image: UIImage()),
WKTabBarItem(title: "Review", image: #imageLiteral(resourceName: "ic_item"), selected: #imageLiteral(resourceName: "ic_item_sel")),
WKTabBarItem(title: "Profile", image: #imageLiteral(resourceName: "ic_item"), selected: #imageLiteral(resourceName: "ic_item_sel")),
]
Expand All @@ -89,19 +89,25 @@ class ViewController: WKTabBarController {
}
}

override func commonInit() {
super.commonInit()

if !IS_IPAD() {
let middleButton = UIButton()
middleButton.setImage(#imageLiteral(resourceName: "ic_middle"), for: .normal)
middleButton.addTarget(self, action: #selector(showModalViewController), for: .touchUpInside)
view.addSubview(middleButton)
middleButton.translatesAutoresizingMaskIntoConstraints = false
middleButton.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
middleButton.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
}
}

override func tabBarController(_ controller: WKTabBarController, customize cell: WKBaseTabBarCell, with item: WKTabBarItem, at index: Int) {
if IS_IPAD() {
if let cell = cell as? WKCustomTabBarImageLabelCell {
cell.isAddButton = index == addButtonIndex
}
} else {
if index == addButtonIndex {
cell.imageSize = 72.0
cell.imageView?.transform = CGAffineTransform(translationX: 0, y: -5)
} else {
cell.imageSize = 22.0
cell.imageView?.transform = CGAffineTransform.identity
}
}
}

Expand All @@ -120,30 +126,45 @@ class ViewController: WKTabBarController {
label.centerYAnchor.constraint(equalTo: vc.view.centerYAnchor).isActive = true

if index == addButtonIndex && !IS_IPAD() {
let button = UIButton(type: .system)
button.setTitle("Close", for: .normal)
button.addTarget(self, action: #selector(didTapCloseButton(_:)), for: .touchUpInside)
vc.view.addSubview(button)
button.translatesAutoresizingMaskIntoConstraints = false
button.centerXAnchor.constraint(equalTo: vc.view.centerXAnchor).isActive = true
button.centerYAnchor.constraint(equalTo: vc.view.centerYAnchor, constant: 50).isActive = true
present(vc, animated: true, completion: nil)
return nil
return nil // Empty space
}

return vc
}

@objc private func showModalViewController() {
let vc = UIViewController()
vc.view.backgroundColor = UIColor(white: 0.95, alpha: 1.0)

let label = UILabel()
label.font = UIFont.systemFont(ofSize: 48)
label.textColor = UIColor(white: 0.8, alpha: 1.0)
label.text = "Modal"

vc.view.addSubview(label)
label.translatesAutoresizingMaskIntoConstraints = false
label.centerXAnchor.constraint(equalTo: vc.view.centerXAnchor).isActive = true
label.centerYAnchor.constraint(equalTo: vc.view.centerYAnchor).isActive = true

let button = UIButton(type: .system)
button.setTitle("Close", for: .normal)
button.addTarget(self, action: #selector(didTapCloseButton(_:)), for: .touchUpInside)
vc.view.addSubview(button)
button.translatesAutoresizingMaskIntoConstraints = false
button.centerXAnchor.constraint(equalTo: vc.view.centerXAnchor).isActive = true
button.centerYAnchor.constraint(equalTo: vc.view.centerYAnchor, constant: 50).isActive = true
present(vc, animated: true, completion: nil)
}

@objc private func didTapCloseButton(_ sender: AnyObject) {
dismiss(animated: true, completion: nil)
}

override func tabBarController(_ controller: WKTabBarController, cellNameAtIndex index: Int) -> WKTabBarCellName {
if (index == addButtonIndex && IS_IPAD()) || (IS_IPAD() && IS_LANDSCAPE()) {
return WKTabBarCellNameCustomImageLabel
} else {
return WKTabBarCellNameImage
}
}

func didTapCloseButton(_ sender: AnyObject) {
dismiss(animated: true, completion: nil)
}

}
2 changes: 1 addition & 1 deletion WKTabBarController/WKTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ open class WKTabBarController: UIViewController, WKTabBarControllerProtocol, UIC
commonInit()
}

func commonInit() {
open func commonInit() {
container = UIView()
container.backgroundColor = UIColor.clear
view.addSubview(container)
Expand Down

0 comments on commit 52f3ab9

Please sign in to comment.