Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
dfa7b8ab
Unverified
Commit
dfa7b8ab
authored
Jul 09, 2018
by
Daniel Dahan
Committed by
GitHub
Jul 09, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1114 from OrkhanAlikhanov/tab-line-width
Added option to adjust tabBar line width
parents
e8ac78ca
4bef332c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
5 deletions
+38
-5
Sources/iOS/TabBar.swift
+38
-5
No files found.
Sources/iOS/TabBar.swift
View file @
dfa7b8ab
...
...
@@ -205,6 +205,12 @@ public enum TabBarCenteringStyle {
case
always
}
public
enum
TabBarLineStyle
{
case
auto
case
fixed
(
CGFloat
)
case
custom
((
TabItem
)
->
CGFloat
)
}
open
class
TabBar
:
Bar
{
/// A dictionary of TabItemLineStates to UIColors for the line.
fileprivate
var
lineColorForState
=
[
TabItemLineState
:
UIColor
]()
...
...
@@ -243,6 +249,13 @@ open class TabBar: Bar {
}
}
/// An enum that determines the tab bar items style.
open
var
tabBarLineStyle
=
TabBarLineStyle
.
auto
{
didSet
{
layoutSubviews
()
}
}
/// A reference to the scroll view when the tab bar style is scrollable.
open
let
scrollView
=
UIScrollView
()
...
...
@@ -486,16 +499,35 @@ fileprivate extension TabBar {
}
guard
shouldNotAnimateLineView
else
{
let
f
=
lineFrame
(
for
:
v
,
forMotion
:
true
)
line
.
animate
(
.
duration
(
0
),
.
size
(
width
:
v
.
bounds
.
width
,
height
:
lineHeight
),
.
position
(
x
:
v
.
center
.
x
,
y
:
.
bottom
==
lineAlignment
?
scrollView
.
bounds
.
height
-
lineHeight
/
2
:
lineHeight
/
2
))
.
size
(
f
.
size
),
.
position
(
f
.
origin
))
return
}
line
.
frame
=
CGRect
(
x
:
v
.
frame
.
origin
.
x
,
y
:
.
bottom
==
lineAlignment
?
scrollView
.
bounds
.
height
-
lineHeight
:
0
,
width
:
v
.
bounds
.
width
,
height
:
lineHeight
)
line
.
frame
=
lineFrame
(
for
:
v
)
shouldNotAnimateLineView
=
false
}
func
lineFrame
(
for
tabItem
:
TabItem
,
forMotion
:
Bool
=
false
)
->
CGRect
{
let
y
=
.
bottom
==
lineAlignment
?
scrollView
.
bounds
.
height
-
(
forMotion
?
lineHeight
/
2
:
lineHeight
)
:
(
forMotion
?
lineHeight
/
2
:
0
)
let
w
:
CGFloat
=
{
switch
tabBarLineStyle
{
case
.
auto
:
return
tabItem
.
bounds
.
width
case
.
fixed
(
let
w
):
return
w
case
.
custom
(
let
closure
):
return
closure
(
tabItem
)
}
}()
let
x
=
forMotion
?
tabItem
.
center
.
x
:
(
tabItem
.
frame
.
origin
.
x
+
(
tabItem
.
bounds
.
width
-
w
)
/
2
)
return
CGRect
(
x
:
x
,
y
:
y
,
width
:
w
,
height
:
lineHeight
)
}
}
extension
TabBar
{
...
...
@@ -612,9 +644,10 @@ fileprivate extension TabBar {
selectedTabItem
=
tabItem
let
f
=
lineFrame
(
for
:
tabItem
,
forMotion
:
true
)
line
.
animate
(
.
duration
(
0.25
),
.
size
(
width
:
tabItem
.
bounds
.
width
,
height
:
lineHeight
),
.
position
(
x
:
tabItem
.
center
.
x
,
y
:
.
bottom
==
lineAlignment
?
scrollView
.
bounds
.
height
-
lineHeight
/
2
:
lineHeight
/
2
),
.
size
(
f
.
size
),
.
position
(
f
.
origin
),
.
completion
({
[
weak
self
,
isTriggeredByUserInteraction
=
isTriggeredByUserInteraction
,
tabItem
=
tabItem
,
completion
=
completion
]
in
guard
let
`
self
`
=
self
else
{
return
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment