Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_sdk_framework
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Manos Chorianopoulos
2022-10-05 18:08:59 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7fdee0bb8ed49b56cd385070598be58e44a2dd13
7fdee0bb
1 parent
37569fec
fix navigation back button
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
8 deletions
SwiftWarplyFramework/SwiftWarplyFramework/ViewControllerExtensions.swift
SwiftWarplyFramework/SwiftWarplyFramework/ViewControllerExtensions.swift
View file @
7fdee0b
...
...
@@ -8,18 +8,21 @@
import
UIKit
extension
UIViewController
{
func
setBackButton
(
_
icon
:
String
=
"ic_back"
)
{
func
setBackButton
(
_
icon
:
String
=
"ic_back
_2
"
)
{
let
uiscreen
:
CGRect
=
UIScreen
.
main
.
bounds
let
backButton
=
UIButton
(
type
:
UIButton
.
ButtonType
.
custom
)
as
UIButton
if
(
icon
==
"ic_close_2"
)
{
backButton
.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
uiscreen
.
height
*
0.035
,
height
:
uiscreen
.
height
*
0.035
)
backButton
.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
18
,
height
:
18
)
}
else
{
backButton
.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
uiscreen
.
height
*
0.035
,
height
:
uiscreen
.
height
*
0.03
)
backButton
.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
18
,
height
:
18
)
}
// backButton.frame = CGRect(x: 0, y: 0, width: uiscreen.height * 0.01, height: uiscreen.height * 0.01)
// backButton.backgroundColor = .red
backButton
.
imageView
!.
contentMode
=
.
scaleAspectFit
//backButton.setBackgroundImage(UIImage(named:Assets.Navigation.backButton), for: UIControlState())
backButton
.
setImage
(
UIImage
(
named
:
icon
,
in
:
Bundle
(
for
:
MyEmptyClass
.
self
),
compatibleWith
:
nil
),
for
:
.
normal
)
// backButton.setImage(UIImage(named: icon), for: .normal)
backButton
.
setBackgroundImage
(
UIImage
(
named
:
icon
),
for
:
.
normal
)
// backButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: -20, bottom: 0, right: 0)
backButton
.
addTarget
(
self
,
action
:
#selector(
moveToBack(_:)
)
,
for
:
.
touchUpInside
)
...
...
@@ -27,16 +30,17 @@ extension UIViewController {
backButton
.
translatesAutoresizingMaskIntoConstraints
=
false
// Add width, height constraints
if
(
icon
==
"ic_close_2"
)
{
let
widthContraints
=
NSLayoutConstraint
(
item
:
backButton
,
attribute
:
NSLayoutConstraint
.
Attribute
.
width
,
relatedBy
:
NSLayoutConstraint
.
Relation
.
equal
,
toItem
:
nil
,
attribute
:
NSLayoutConstraint
.
Attribute
.
notAnAttribute
,
multiplier
:
1
,
constant
:
uiscreen
.
height
*
0.035
)
let
heightContraints
=
NSLayoutConstraint
(
item
:
backButton
,
attribute
:
NSLayoutConstraint
.
Attribute
.
height
,
relatedBy
:
NSLayoutConstraint
.
Relation
.
equal
,
toItem
:
nil
,
attribute
:
NSLayoutConstraint
.
Attribute
.
notAnAttribute
,
multiplier
:
1
,
constant
:
uiscreen
.
height
*
0.035
)
let
widthContraints
=
NSLayoutConstraint
(
item
:
backButton
,
attribute
:
NSLayoutConstraint
.
Attribute
.
width
,
relatedBy
:
NSLayoutConstraint
.
Relation
.
equal
,
toItem
:
nil
,
attribute
:
NSLayoutConstraint
.
Attribute
.
notAnAttribute
,
multiplier
:
1
,
constant
:
18
)
let
heightContraints
=
NSLayoutConstraint
(
item
:
backButton
,
attribute
:
NSLayoutConstraint
.
Attribute
.
height
,
relatedBy
:
NSLayoutConstraint
.
Relation
.
equal
,
toItem
:
nil
,
attribute
:
NSLayoutConstraint
.
Attribute
.
notAnAttribute
,
multiplier
:
1
,
constant
:
18
)
NSLayoutConstraint
.
activate
([
heightContraints
,
widthContraints
])
}
else
{
let
widthContraints
=
NSLayoutConstraint
(
item
:
backButton
,
attribute
:
NSLayoutConstraint
.
Attribute
.
width
,
relatedBy
:
NSLayoutConstraint
.
Relation
.
equal
,
toItem
:
nil
,
attribute
:
NSLayoutConstraint
.
Attribute
.
notAnAttribute
,
multiplier
:
1
,
constant
:
uiscreen
.
height
*
0.035
)
let
heightContraints
=
NSLayoutConstraint
(
item
:
backButton
,
attribute
:
NSLayoutConstraint
.
Attribute
.
height
,
relatedBy
:
NSLayoutConstraint
.
Relation
.
equal
,
toItem
:
nil
,
attribute
:
NSLayoutConstraint
.
Attribute
.
notAnAttribute
,
multiplier
:
1
,
constant
:
uiscreen
.
height
*
0.03
)
let
widthContraints
=
NSLayoutConstraint
(
item
:
backButton
,
attribute
:
NSLayoutConstraint
.
Attribute
.
width
,
relatedBy
:
NSLayoutConstraint
.
Relation
.
equal
,
toItem
:
nil
,
attribute
:
NSLayoutConstraint
.
Attribute
.
notAnAttribute
,
multiplier
:
1
,
constant
:
18
)
let
heightContraints
=
NSLayoutConstraint
(
item
:
backButton
,
attribute
:
NSLayoutConstraint
.
Attribute
.
height
,
relatedBy
:
NSLayoutConstraint
.
Relation
.
equal
,
toItem
:
nil
,
attribute
:
NSLayoutConstraint
.
Attribute
.
notAnAttribute
,
multiplier
:
1
,
constant
:
18
)
NSLayoutConstraint
.
activate
([
heightContraints
,
widthContraints
])
}
let
leftBarButtonItem
:
UIBarButtonItem
=
UIBarButtonItem
(
customView
:
backButton
)
NSLayoutConstraint
.
activate
([(
leftBarButtonItem
.
customView
!.
widthAnchor
.
constraint
(
equalToConstant
:
18
)),(
leftBarButtonItem
.
customView
!.
heightAnchor
.
constraint
(
equalToConstant
:
18
))])
self
.
navigationItem
.
setLeftBarButton
(
leftBarButtonItem
,
animated
:
false
)
self
.
navigationItem
.
title
=
""
...
...
Please
register
or
login
to post a comment