Manos Chorianopoulos

add navbar at ViewControllerExtensions

......@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
1E7564BA2823C6D900B9D2AE /* ViewControllerExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E7564B92823C6D900B9D2AE /* ViewControllerExtensions.swift */; };
1EBB036F281BE3610062F663 /* RSBarcodes_Swift in Frameworks */ = {isa = PBXBuildFile; productRef = 1EBB036E281BE3610062F663 /* RSBarcodes_Swift */; };
260C6A1AFF7560C32E212F20 /* Pods_WarplySDKFrameworkIOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1353B8C484CC0649CAC2EB74 /* Pods_WarplySDKFrameworkIOS.framework */; };
E634A369282299770069DE27 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E634A368282299760069DE27 /* Main.storyboard */; };
......@@ -132,6 +133,7 @@
/* Begin PBXFileReference section */
1353B8C484CC0649CAC2EB74 /* Pods_WarplySDKFrameworkIOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_WarplySDKFrameworkIOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
1E7564B92823C6D900B9D2AE /* ViewControllerExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewControllerExtensions.swift; sourceTree = "<group>"; };
B9413513157AD76ECE896B81 /* Pods-WarplySDKFrameworkIOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WarplySDKFrameworkIOS.release.xcconfig"; path = "Target Support Files/Pods-WarplySDKFrameworkIOS/Pods-WarplySDKFrameworkIOS.release.xcconfig"; sourceTree = "<group>"; };
E634A368282299760069DE27 /* Main.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
E634A36A2822999B0069DE27 /* CouponsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponsViewController.swift; sourceTree = "<group>"; };
......@@ -328,6 +330,7 @@
E67D1EC528117F2400940F01 /* swiftApi.swift */,
E634A368282299760069DE27 /* Main.storyboard */,
E634A36A2822999B0069DE27 /* CouponsViewController.swift */,
1E7564B92823C6D900B9D2AE /* ViewControllerExtensions.swift */,
);
path = WarplySDKFrameworkIOS;
sourceTree = "<group>";
......@@ -732,6 +735,7 @@
E6D8DF2927A942920006A3A9 /* NSData+SSToolkitAdditions.m in Sources */,
E6D8DEFC27A942920006A3A9 /* WLCustomNativeAdTableViewCell.m in Sources */,
E6D8DF4A27A942920006A3A9 /* AFNetworkReachabilityManager.m in Sources */,
1E7564BA2823C6D900B9D2AE /* ViewControllerExtensions.swift in Sources */,
E6D8DF4B27A942920006A3A9 /* AFSecurityPolicy.m in Sources */,
E6D8DF1327A942920006A3A9 /* WLBeaconManager.m in Sources */,
E6D8DF0427A942920006A3A9 /* WLInboxItem.m in Sources */,
......
//
// ViewControllerExtensions.swift
// WarplySDKFrameworkIOS
//
// Created by Manos Chorianopoulos on 5/5/22.
//
import UIKit
extension UIViewController {
func setBackButton() {
let uiscreen: CGRect = UIScreen.main.bounds
let backButton = UIButton(type: UIButton.ButtonType.custom) as UIButton
backButton.frame = CGRect(x: 0, y: 0, width: uiscreen.height * 0.025, height: uiscreen.height * 0.02)
backButton.imageView!.contentMode = .scaleAspectFit
//backButton.setBackgroundImage(UIImage(named:Assets.Navigation.backButton), for: UIControlState())
backButton.setImage(UIImage(named: "ic_back"), for: .normal)
// backButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: -20, bottom: 0, right: 0)
backButton.addTarget(self, action: #selector(moveToBack(_:)), for: .touchUpInside)
backButton.translatesAutoresizingMaskIntoConstraints = false
// Add width, height constraints
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.025)
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.02)
NSLayoutConstraint.activate([heightContraints,widthContraints])
let leftBarButtonItem: UIBarButtonItem = UIBarButtonItem(customView: backButton)
self.navigationItem.setLeftBarButton(leftBarButtonItem, animated: false)
self.navigationItem.title = ""
}
@objc func moveToBack(_ sender:UIButton){
self.navigationController?.popViewController(animated: true)
}
func setNavigationTitle(_ title: String) {
let uiscreen: CGRect = UIScreen.main.bounds
let titleLabel = UILabel(frame: CGRect(x: 0, y: 0, width: uiscreen.width * 0.7, height: uiscreen.height * 0.03))
titleLabel.text = title
titleLabel.textColor = UIColor(red: 0.21, green: 0.32, blue: 0.41, alpha: 1.00)
titleLabel.font = UIFont.systemFont(ofSize: 16, weight: UIFont.Weight.medium)
titleLabel.adjustsFontSizeToFitWidth = true
titleLabel.textAlignment = .center
self.navigationItem.titleView = titleLabel
}
}