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
f3408e13
Commit
f3408e13
authored
Aug 21, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: added image and title convenience initializer methods to Button class
parent
4f72b9fa
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
21 deletions
+64
-21
Sources/iOS/Button.swift
+58
-0
Sources/iOS/NavigationController.swift
+2
-4
Sources/iOS/SearchBar.swift
+1
-5
Sources/iOS/TextField.swift
+3
-12
No files found.
Sources/iOS/Button.swift
View file @
f3408e13
...
@@ -84,6 +84,24 @@ open class Button: UIButton {
...
@@ -84,6 +84,24 @@ open class Button: UIButton {
}
}
}
}
/// Sets the normal and highlighted title for the button.
@IBInspectable
open
var
title
:
String
?
{
didSet
{
setTitle
(
title
,
for
:
.
normal
)
setTitle
(
title
,
for
:
.
highlighted
)
}
}
/// Sets the normal and highlighted titleColor for the button.
@IBInspectable
open
var
titleColor
:
UIColor
?
{
didSet
{
setTitleColor
(
titleColor
,
for
:
.
normal
)
setTitleColor
(
titleColor
,
for
:
.
highlighted
)
}
}
/**
/**
An initializer that initializes the object with a NSCoder object.
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
- Parameter aDecoder: A NSCoder instance.
...
@@ -108,6 +126,46 @@ open class Button: UIButton {
...
@@ -108,6 +126,46 @@ open class Button: UIButton {
public
convenience
init
()
{
public
convenience
init
()
{
self
.
init
(
frame
:
CGRect
.
zero
)
self
.
init
(
frame
:
CGRect
.
zero
)
}
}
/**
A convenience initializer that acceps an image.
- Parameter image: A UIImage.
*/
public
convenience
init
(
image
:
UIImage
?)
{
self
.
init
()
self
.
image
=
image
}
/**
A convenience initializer that acceps an image and tintColor.
- Parameter image: A UIImage.
- Parameter tintColor: A UIColor.
*/
public
convenience
init
(
image
:
UIImage
?,
tintColor
:
UIColor
?)
{
self
.
init
()
self
.
image
=
image
self
.
tintColor
=
tintColor
}
/**
A convenience initializer that acceps a title.
- Parameter title: A String.
*/
public
convenience
init
(
title
:
String
?)
{
self
.
init
()
self
.
title
=
title
}
/**
A convenience initializer that acceps a title and titleColor.
- Parameter title: A String.
- Parameter titleColor: A UIColor.
*/
public
convenience
init
(
title
:
String
?,
titleColor
:
UIColor
?)
{
self
.
init
()
self
.
title
=
title
self
.
titleColor
=
titleColor
}
open
override
func
layoutSublayers
(
of
layer
:
CALayer
)
{
open
override
func
layoutSublayers
(
of
layer
:
CALayer
)
{
super
.
layoutSublayers
(
of
:
layer
)
super
.
layoutSublayers
(
of
:
layer
)
...
...
Sources/iOS/NavigationController.swift
View file @
f3408e13
...
@@ -108,11 +108,9 @@ open class NavigationController: UINavigationController, UIGestureRecognizerDele
...
@@ -108,11 +108,9 @@ open class NavigationController: UINavigationController, UIGestureRecognizerDele
*/
*/
open
func
navigationBar
(
navigationBar
:
UINavigationBar
,
shouldPushItem
item
:
UINavigationItem
)
->
Bool
{
open
func
navigationBar
(
navigationBar
:
UINavigationBar
,
shouldPushItem
item
:
UINavigationItem
)
->
Bool
{
if
let
v
=
navigationBar
as?
NavigationBar
{
if
let
v
=
navigationBar
as?
NavigationBar
{
let
backButton
=
IconButton
(
)
let
backButton
=
IconButton
(
image
:
v
.
backButtonImage
)
backButton
.
pulseColor
=
Color
.
white
backButton
.
pulseColor
=
Color
.
white
backButton
.
setImage
(
v
.
backButtonImage
,
for
:
.
normal
)
backButton
.
addTarget
(
self
,
action
:
#selector(
handleBackButton
)
,
for
:
.
touchUpInside
)
backButton
.
setImage
(
v
.
backButtonImage
,
for
:
.
highlighted
)
backButton
.
addTarget
(
self
,
action
:
#selector(
handleBackButton
)
,
for
:
.
touchUpInside
)
if
var
c
=
item
.
leftControls
{
if
var
c
=
item
.
leftControls
{
c
.
append
(
backButton
)
c
.
append
(
backButton
)
...
...
Sources/iOS/SearchBar.swift
View file @
f3408e13
...
@@ -159,12 +159,8 @@ public class SearchBar: BarView {
...
@@ -159,12 +159,8 @@ public class SearchBar: BarView {
/// Prepares the clearButton.
/// Prepares the clearButton.
private
func
prepareClearButton
()
{
private
func
prepareClearButton
()
{
let
image
:
UIImage
?
=
Icon
.
cm
.
close
clearButton
=
IconButton
(
image
:
Icon
.
cm
.
close
,
tintColor
:
placeholderColor
)
clearButton
=
IconButton
()
clearButton
.
contentEdgeInsets
=
UIEdgeInsets
.
zero
clearButton
.
contentEdgeInsets
=
UIEdgeInsets
.
zero
clearButton
.
tintColor
=
placeholderColor
clearButton
.
setImage
(
image
,
for
:
.
normal
)
clearButton
.
setImage
(
image
,
for
:
.
highlighted
)
clearButtonAutoHandleEnabled
=
true
clearButtonAutoHandleEnabled
=
true
textField
.
clearButtonMode
=
.
never
textField
.
clearButtonMode
=
.
never
textField
.
rightViewMode
=
.
whileEditing
textField
.
rightViewMode
=
.
whileEditing
...
...
Sources/iOS/TextField.swift
View file @
f3408e13
...
@@ -206,14 +206,10 @@ open class TextField: UITextField {
...
@@ -206,14 +206,10 @@ open class TextField: UITextField {
set
(
value
)
{
set
(
value
)
{
if
value
{
if
value
{
if
nil
==
clearIconButton
{
if
nil
==
clearIconButton
{
let
image
:
UIImage
?
=
Icon
.
cm
.
clear
clearIconButton
=
IconButton
(
image
:
Icon
.
cm
.
clear
,
tintColor
:
placeholderColor
)
clearIconButton
=
IconButton
(
frame
:
CGRect
.
zero
)
clearIconButton
!.
contentEdgeInsets
=
UIEdgeInsets
.
zero
clearIconButton
!.
contentEdgeInsets
=
UIEdgeInsets
.
zero
clearIconButton
!.
pulseAnimation
=
.
center
clearIconButton
!.
pulseAnimation
=
.
center
clearIconButton
!.
tintColor
=
placeholderColor
clearButtonMode
=
.
never
clearIconButton
!.
setImage
(
image
,
for
:
.
normal
)
clearIconButton
!.
setImage
(
image
,
for
:
.
highlighted
)
clearButtonMode
=
.
never
rightViewMode
=
.
whileEditing
rightViewMode
=
.
whileEditing
rightView
=
clearIconButton
rightView
=
clearIconButton
clearIconButtonAutoHandle
=
clearIconButtonAutoHandle
?
true
:
false
clearIconButtonAutoHandle
=
clearIconButtonAutoHandle
?
true
:
false
...
@@ -245,14 +241,9 @@ open class TextField: UITextField {
...
@@ -245,14 +241,9 @@ open class TextField: UITextField {
set
(
value
)
{
set
(
value
)
{
if
value
{
if
value
{
if
nil
==
visibilityIconButton
{
if
nil
==
visibilityIconButton
{
let
image
:
UIImage
?
=
Icon
.
visibility
visibilityIconButton
=
IconButton
(
image
:
Icon
.
visibility
,
tintColor
:
placeholderColor
.
withAlphaComponent
(
isSecureTextEntry
?
0.38
:
0.54
))
visibilityIconButton
=
IconButton
(
frame
:
CGRect
.
zero
)
visibilityIconButton
!.
contentEdgeInsets
=
UIEdgeInsets
.
zero
visibilityIconButton
!.
contentEdgeInsets
=
UIEdgeInsets
.
zero
visibilityIconButton
!.
pulseAnimation
=
.
center
visibilityIconButton
!.
pulseAnimation
=
.
center
visibilityIconButton
!.
tintColor
=
placeholderColor
visibilityIconButton
!.
setImage
(
image
,
for
:
.
normal
)
visibilityIconButton
!.
setImage
(
image
,
for
:
.
highlighted
)
visibilityIconButton
!.
tintColor
=
placeholderColor
.
withAlphaComponent
(
isSecureTextEntry
?
0.38
:
0.54
)
isSecureTextEntry
=
true
isSecureTextEntry
=
true
clearButtonMode
=
.
never
clearButtonMode
=
.
never
rightViewMode
=
.
whileEditing
rightViewMode
=
.
whileEditing
...
...
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