Skip to content

Commit

Permalink
add some screen shot and modify access level modifer
Browse files Browse the repository at this point in the history
  • Loading branch information
ragaie committed Nov 10, 2019
1 parent 2e6a782 commit e543eed
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 50 deletions.
Binary file added IMG_3325.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added ScreenShot1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
51 changes: 11 additions & 40 deletions TopTabBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,22 @@

import UIKit

@IBDesignable class TopTabBar: UIView {


private var containerView: UIView!
@IBDesignable open class TopTabBar: UIView {
@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var stackViewContainer: UIStackView!
@IBOutlet open weak var stackViewContainer: UIStackView!
@IBOutlet weak var linebar: UILabel!

var delegte : TopTabBarDelegate?

private var lineIndecator : UILabel!
// private var ContainerView : UIView!
private var tabButtons : [UIButton]! = []
private var selectIndex : Int! = 0
public var buttonTitle : [String]! = []
public var buttonImges : [UIImage]! = []
public var buttonImgesHighLight : [UIImage]! = []
open var buttonTitle : [String]! = []
open var buttonImges : [UIImage]! = []
open var buttonImgesHighLight : [UIImage]! = []

open var delegte : TopTabBarDelegate?
open var font : UIFont = UIFont.systemFont(ofSize: 12)


//MARK: Initializers
//MARK: tabbar parameter
@IBInspectable var buttonNumber : Int = 0 {
Expand All @@ -36,7 +35,6 @@ import UIKit
}

}
var font : UIFont = UIFont.systemFont(ofSize: 12)

@IBInspectable var barBackgroundColor : UIColor = UIColor.blue {
didSet{
Expand Down Expand Up @@ -108,14 +106,12 @@ import UIKit

}

override func layoutSubviews() {
override open func layoutSubviews() {
super.layoutSubviews()
addLineBar()
setButtons()
//wait until button renders in screen to get same width of it and display it.
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
// do stuff 42 seconds later

if self.tabButtons.count > 0{
self.setupButtonIndicator(sender: self.tabButtons[0])
}
Expand Down Expand Up @@ -169,15 +165,11 @@ import UIKit
if tabButtons.count > 0 {
if buttonTitle.count > 0 {
for item in tabButtons {

item.setTitleColor(textColor, for: .normal)
item.backgroundColor = .clear
}

tabButtons[sender.tag].setTitleColor(titleTint, for: .normal)
tabButtons[sender.tag].backgroundColor = itemBackgroundColor


}
else if buttonImges.count > 0 {
for item in tabButtons {
Expand Down Expand Up @@ -207,16 +199,12 @@ import UIKit
//and add button object depend the button number
if buttonNumber > 0 {
for i in 0...(buttonNumber - 1){

let tempButton = UIButton.init(frame: CGRect.init(x: 0 , y: 0, width: 10 , height: 0))

tempButton.contentEdgeInsets = UIEdgeInsets.init(top: 0, left: contentInsets, bottom: 0, right: contentInsets)
tempButton.titleLabel?.font = font
/// set titles of button in view
if buttonTitle.count > 0 {

if i < buttonTitle.count {

tempButton.setTitle( buttonTitle[i], for: .normal)
}
else{
Expand All @@ -237,10 +225,8 @@ import UIKit
tempButton.backgroundColor = .clear
tempButton.tag = i
tabButtons.append(tempButton)
// addSubview(tempButton)
stackViewContainer.addArrangedSubview(tempButton)
//need to add indicator

}
// set action in all button
initActionAndDelegete()
Expand All @@ -261,12 +247,9 @@ import UIKit
}

func setupButtonIndicator(sender : UIButton ){

//remove line indicator
if tabButtons.count > 0 {

for item in tabButtons {

for subItem in item.subviews{
if subItem.restorationIdentifier == "lineIndicate"{
subItem.removeFromSuperview()
Expand All @@ -275,9 +258,7 @@ import UIKit
//update button color
item.backgroundColor = .clear
item.setTitleColor(textColor, for: .normal)

}

}
//add line indicator
let lineIndicate = UILabel.init(frame: CGRect.init(x: (0 - spaceing / 2), y: sender.frame.height - lineHight , width: sender.frame.width + spaceing , height: lineHight))
Expand Down Expand Up @@ -323,13 +304,3 @@ import UIKit
}
}

//extension UIView {
// func shake() {
// let animation = CAKeyframeAnimation(keyPath: "transform.translation.x")
// animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear)
// animation.duration = 0.9
// animation.values = [-15.0, 15.0, -15.0, 15.0, -7.0, 7.0, -2.50, 2.50, 0.0 ]
// layer.add(animation, forKey: "shake")
// }
//
//}
2 changes: 1 addition & 1 deletion TopTabBarDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import UIKit

protocol TopTabBarDelegate {
public protocol TopTabBarDelegate {

func topTabBarSelected (index : Int)

Expand Down
Binary file added tabBarMovie.mov
Binary file not shown.
28 changes: 20 additions & 8 deletions topTabBar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
81BB8C321F559FC1001F53B3 /* Location.png in Resources */ = {isa = PBXBuildFile; fileRef = 81BB8C311F559FC1001F53B3 /* Location.png */; };
81BB8C351F55A5BA001F53B3 /* house-h.png in Resources */ = {isa = PBXBuildFile; fileRef = 81BB8C331F55A5BA001F53B3 /* house-h.png */; };
81BB8C361F55A5BA001F53B3 /* house.png in Resources */ = {isa = PBXBuildFile; fileRef = 81BB8C341F55A5BA001F53B3 /* house.png */; };
DF1E0E782371D078008A2FF7 /* Simulator Screen Shot - iPhone Xʀ - 2019-11-05 at 17.44.37.png in Resources */ = {isa = PBXBuildFile; fileRef = DF1E0E762371D077008A2FF7 /* Simulator Screen Shot - iPhone Xʀ - 2019-11-05 at 17.44.37.png */; };
DF1E0E792371D078008A2FF7 /* Screen Shot 2019-11-05 at 5.44.21 PM.png in Resources */ = {isa = PBXBuildFile; fileRef = DF1E0E772371D077008A2FF7 /* Screen Shot 2019-11-05 at 5.44.21 PM.png */; };
DF1E0E782371D078008A2FF7 /* ScreenShot2.png in Resources */ = {isa = PBXBuildFile; fileRef = DF1E0E762371D077008A2FF7 /* ScreenShot2.png */; };
DF1E0E792371D078008A2FF7 /* ScreenShot1.png in Resources */ = {isa = PBXBuildFile; fileRef = DF1E0E772371D077008A2FF7 /* ScreenShot1.png */; };
DF2875A52378140500BB7553 /* tabBarMovie.mov in Resources */ = {isa = PBXBuildFile; fileRef = DF2875A42378140500BB7553 /* tabBarMovie.mov */; };
DF2875A72378144800BB7553 /* Screen Shot3.png in Resources */ = {isa = PBXBuildFile; fileRef = DF2875A62378144700BB7553 /* Screen Shot3.png */; };
DF2875A92378151D00BB7553 /* IMG_3325.jpg in Resources */ = {isa = PBXBuildFile; fileRef = DF2875A82378151D00BB7553 /* IMG_3325.jpg */; };
DF649FE62376D386008EF633 /* TopTabBar-Chtar.podspec in Resources */ = {isa = PBXBuildFile; fileRef = DF649FE52376D386008EF633 /* TopTabBar-Chtar.podspec */; };
DFFAEB862338C6AC00D0EA08 /* TopTabBarDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFFAEB852338C6AC00D0EA08 /* TopTabBarDelegate.swift */; };
/* End PBXBuildFile section */
Expand All @@ -38,8 +41,11 @@
81BB8C311F559FC1001F53B3 /* Location.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Location.png; sourceTree = "<group>"; };
81BB8C331F55A5BA001F53B3 /* house-h.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "house-h.png"; sourceTree = "<group>"; };
81BB8C341F55A5BA001F53B3 /* house.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = house.png; sourceTree = "<group>"; };
DF1E0E762371D077008A2FF7 /* Simulator Screen Shot - iPhone Xʀ - 2019-11-05 at 17.44.37.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Simulator Screen Shot - iPhone Xʀ - 2019-11-05 at 17.44.37.png"; sourceTree = "<group>"; };
DF1E0E772371D077008A2FF7 /* Screen Shot 2019-11-05 at 5.44.21 PM.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Screen Shot 2019-11-05 at 5.44.21 PM.png"; sourceTree = "<group>"; };
DF1E0E762371D077008A2FF7 /* ScreenShot2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ScreenShot2.png; sourceTree = "<group>"; };
DF1E0E772371D077008A2FF7 /* ScreenShot1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ScreenShot1.png; sourceTree = "<group>"; };
DF2875A42378140500BB7553 /* tabBarMovie.mov */ = {isa = PBXFileReference; lastKnownFileType = video.quicktime; path = tabBarMovie.mov; sourceTree = "<group>"; };
DF2875A62378144700BB7553 /* Screen Shot3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Screen Shot3.png"; sourceTree = "<group>"; };
DF2875A82378151D00BB7553 /* IMG_3325.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = IMG_3325.jpg; sourceTree = "<group>"; };
DF649FE52376D386008EF633 /* TopTabBar-Chtar.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "TopTabBar-Chtar.podspec"; sourceTree = "<group>"; };
DFFAEB852338C6AC00D0EA08 /* TopTabBarDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopTabBarDelegate.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand All @@ -58,8 +64,11 @@
819560BC1F56C0A1005B59C3 /* screen shot */ = {
isa = PBXGroup;
children = (
DF1E0E772371D077008A2FF7 /* Screen Shot 2019-11-05 at 5.44.21 PM.png */,
DF1E0E762371D077008A2FF7 /* Simulator Screen Shot - iPhone Xʀ - 2019-11-05 at 17.44.37.png */,
DF2875A42378140500BB7553 /* tabBarMovie.mov */,
DF2875A82378151D00BB7553 /* IMG_3325.jpg */,
DF1E0E772371D077008A2FF7 /* ScreenShot1.png */,
DF2875A62378144700BB7553 /* Screen Shot3.png */,
DF1E0E762371D077008A2FF7 /* ScreenShot2.png */,
81BB8C331F55A5BA001F53B3 /* house-h.png */,
81BB8C341F55A5BA001F53B3 /* house.png */,
81BB8C311F559FC1001F53B3 /* Location.png */,
Expand Down Expand Up @@ -172,16 +181,19 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DF2875A92378151D00BB7553 /* IMG_3325.jpg in Resources */,
819702DF1F5318B1005927D9 /* LaunchScreen.storyboard in Resources */,
819702E81F5318EE005927D9 /* TopTabBar.xib in Resources */,
DF1E0E792371D078008A2FF7 /* Screen Shot 2019-11-05 at 5.44.21 PM.png in Resources */,
DF1E0E792371D078008A2FF7 /* ScreenShot1.png in Resources */,
DF2875A52378140500BB7553 /* tabBarMovie.mov in Resources */,
819702DC1F5318B1005927D9 /* Assets.xcassets in Resources */,
81BB8C321F559FC1001F53B3 /* Location.png in Resources */,
81BB8C361F55A5BA001F53B3 /* house.png in Resources */,
81BB8C351F55A5BA001F53B3 /* house-h.png in Resources */,
819560CB1F56C0BD005B59C3 /* Screen Shot 2017-08-30 at 11.43.25 AM.png in Resources */,
DF2875A72378144800BB7553 /* Screen Shot3.png in Resources */,
DF649FE62376D386008EF633 /* TopTabBar-Chtar.podspec in Resources */,
DF1E0E782371D078008A2FF7 /* Simulator Screen Shot - iPhone Xʀ - 2019-11-05 at 17.44.37.png in Resources */,
DF1E0E782371D078008A2FF7 /* ScreenShot2.png in Resources */,
819702DA1F5318B1005927D9 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
2 changes: 1 addition & 1 deletion topTabBar/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ViewController: UIViewController ,TopTabBarDelegate{
thirdBar.buttonTitle = ["Dining","Shopping","Night Life","Health","Sport","Travel"]
ToptabBarOutlet.delegte = self

thirdBar.buttonImges = [UIImage.init(named: "Location"),UIImage.init(named: "Location"),UIImage.init(named: "Location"),UIImage.init(named: "Location")] as! [UIImage]
// thirdBar.buttonImges = [UIImage.init(named: "Location"),UIImage.init(named: "Location"),UIImage.init(named: "Location"),UIImage.init(named: "Location")] as! [UIImage]
}

override func didReceiveMemoryWarning() {
Expand Down

0 comments on commit e543eed

Please sign in to comment.