Skip to content

Commit

Permalink
fixes issue #4 & #5
Browse files Browse the repository at this point in the history
  • Loading branch information
perteadrian committed Mar 5, 2019
1 parent 10cea1b commit fdd7a10
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 22 deletions.
Binary file modified .DS_Store
Binary file not shown.
34 changes: 14 additions & 20 deletions CircleBar/Classes/SHCircleBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,32 +41,28 @@ class SHCircleBarController: UITabBarController {
super.viewDidLoad()
let tabBar = SHCircleBar()
self.setValue(tabBar, forKey: "tabBar")

}
open override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let tabWidth = self.view.bounds.width / CGFloat(self.tabBar.items!.count)

circleView = UIView(frame: CGRect(x: tabWidth / 2 - 30 - self.view.safeAreaInsets.bottom, y: self.tabBar.frame.origin.y - 40, width: 60, height: 60))

self.circleView = UIView(frame: .zero)
circleView.layer.cornerRadius = 30
circleView.backgroundColor = .white
circleView.isUserInteractionEnabled = false

circleImageView = UIImageView(frame: self.circleView.bounds)
self.circleImageView = UIImageView(frame: .zero)
circleImageView.layer.cornerRadius = 30
circleImageView.isUserInteractionEnabled = false
circleImageView.contentMode = .center
circleImageView.image = image(with: self.tabBar.selectedItem?.image, scaledTo: CGSize(width: 30, height: 30))


circleView.addSubview(circleImageView)
self.view.addSubview(circleView)

let tabWidth = self.view.bounds.width / CGFloat(self.tabBar.items?.count ?? 4)

circleView.frame = CGRect(x: tabWidth / 2 - 30, y: self.tabBar.frame.origin.y - 40, width: 60, height: 60)
circleImageView.frame = self.circleView.bounds
}

open override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)


open override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
circleImageView.image = image(with: self.tabBar.selectedItem?.image ?? self.tabBar.items?.first?.image, scaledTo: CGSize(width: 30, height: 30))

}

private var _barHeight: CGFloat = 74
Expand Down Expand Up @@ -105,10 +101,8 @@ class SHCircleBarController: UITabBarController {
}

open override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
guard let idx = tabBar.items?.index(of: item) else {
return
}
if let controller = viewControllers?[idx] {
guard let idx = tabBar.items?.index(of: item) else { return }
if idx != selectedIndex, let controller = viewControllers?[idx] {
shouldSelectOnTabBar = false
selectedIndex = idx
let tabWidth = self.view.bounds.width / CGFloat(self.tabBar.items!.count)
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "0"
version = "2.0">
</Bucket>
Binary file added Example/CircleBar/.DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ pod 'CircleBar'
# Usage
1. Create a new `UITabBarController` in your storyboard or nib.

2. Set the class of the `UITabBarController` to `SHTabBarController` in your Storyboard or nib.
2. Set the class of the `UITabBarController` to `SHCircleController` in your Storyboard or nib.

3. Set the class of the `UITabBar` of `SHTabBarController` to `SHTabBar` in your Storyboard or nib.
3. Set the class of the `UITabBar` of `SHTabBarController` to `SHCircleBar` in your Storyboard or nib.

4. Add a custom image icon and title for `UITabBarItem` of each child `UIViewContrroller`.

Expand Down

0 comments on commit fdd7a10

Please sign in to comment.