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
41f41bcc
Commit
41f41bcc
authored
Jul 25, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working scrollable TabBar
parent
4ca95ebc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
17 deletions
+12
-17
Sources/iOS/TabBar.swift
+12
-17
No files found.
Sources/iOS/TabBar.swift
View file @
41f41bcc
...
@@ -292,12 +292,12 @@ open class TabBar: Bar {
...
@@ -292,12 +292,12 @@ open class TabBar: Bar {
}
}
scrollView
.
contentSize
=
CGSize
(
width
:
w
,
height
:
height
)
scrollView
.
contentSize
=
CGSize
(
width
:
w
,
height
:
height
)
scrollView
.
addSubview
(
line
)
}
else
{
}
else
{
contentView
.
grid
.
axis
.
columns
=
buttons
.
count
contentView
.
grid
.
axis
.
columns
=
buttons
.
count
centerViews
=
buttons
centerViews
=
buttons
}
addSubview
(
line
)
addSubview
(
line
)
}
updateSelectionLine
()
updateSelectionLine
()
}
}
...
@@ -338,7 +338,6 @@ extension TabBar {
...
@@ -338,7 +338,6 @@ extension TabBar {
line
.
zPosition
=
6000
line
.
zPosition
=
6000
lineColor
=
Color
.
blue
.
base
lineColor
=
Color
.
blue
.
base
lineHeight
=
3
lineHeight
=
3
scrollView
.
addSubview
(
line
)
}
}
/// Prepares the divider.
/// Prepares the divider.
...
@@ -419,20 +418,10 @@ extension TabBar {
...
@@ -419,20 +418,10 @@ extension TabBar {
selected
=
button
selected
=
button
isAnimating
=
true
isAnimating
=
true
UIView
.
animate
(
withDuration
:
0.25
,
animations
:
{
[
weak
self
,
button
=
button
]
in
line
.
animate
(
.
duration
(
0.25
),
guard
let
s
=
self
else
{
.
size
(
CGSize
(
width
:
button
.
width
,
height
:
lineHeight
)),
return
.
position
(
CGPoint
(
x
:
button
.
center
.
x
,
y
:
.
bottom
==
lineAlignment
?
height
-
lineHeight
:
0
)),
}
.
completion
{
[
weak
self
,
isTriggeredByUserInteraction
=
isTriggeredByUserInteraction
,
button
=
button
,
completion
=
completion
]
_
in
s
.
line
.
width
=
button
.
width
s
.
line
.
center
.
x
=
button
.
center
.
x
if
!
s
.
scrollView
.
bounds
.
contains
(
button
.
frame
)
{
let
contentOffsetX
=
(
button
.
x
<
s
.
scrollView
.
bounds
.
minX
)
?
button
.
x
:
button
.
frame
.
maxX
-
s
.
scrollView
.
bounds
.
width
let
normalizedOffsetX
=
min
(
max
(
contentOffsetX
,
0
),
s
.
scrollView
.
contentSize
.
width
-
s
.
scrollView
.
bounds
.
width
)
s
.
scrollView
.
setContentOffset
(
CGPoint
(
x
:
normalizedOffsetX
,
y
:
0
),
animated
:
false
)
}
})
{
[
weak
self
,
isTriggeredByUserInteraction
=
isTriggeredByUserInteraction
,
button
=
button
,
completion
=
completion
]
_
in
guard
let
s
=
self
else
{
guard
let
s
=
self
else
{
return
return
}
}
...
@@ -444,6 +433,12 @@ extension TabBar {
...
@@ -444,6 +433,12 @@ extension TabBar {
}
}
completion
?(
button
)
completion
?(
button
)
})
if
!
scrollView
.
bounds
.
contains
(
button
.
frame
)
{
let
contentOffsetX
=
(
button
.
x
<
scrollView
.
bounds
.
minX
)
?
button
.
x
:
button
.
frame
.
maxX
-
scrollView
.
bounds
.
width
let
normalizedOffsetX
=
min
(
max
(
contentOffsetX
,
0
),
scrollView
.
contentSize
.
width
-
scrollView
.
bounds
.
width
)
scrollView
.
setContentOffset
(
CGPoint
(
x
:
normalizedOffsetX
,
y
:
0
),
animated
:
true
)
}
}
}
}
}
}
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