Showing
4 changed files
with
50 additions
and
31 deletions
| ... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
| 7 | <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key> | 7 | <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key> |
| 8 | <dict> | 8 | <dict> |
| 9 | <key>orderHint</key> | 9 | <key>orderHint</key> |
| 10 | - <integer>0</integer> | 10 | + <integer>1</integer> |
| 11 | </dict> | 11 | </dict> |
| 12 | </dict> | 12 | </dict> |
| 13 | </dict> | 13 | </dict> | ... | ... |
| ... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
| 7 | <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key> | 7 | <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key> |
| 8 | <dict> | 8 | <dict> |
| 9 | <key>orderHint</key> | 9 | <key>orderHint</key> |
| 10 | - <integer>1</integer> | 10 | + <integer>0</integer> |
| 11 | </dict> | 11 | </dict> |
| 12 | </dict> | 12 | </dict> |
| 13 | </dict> | 13 | </dict> | ... | ... |
No preview for this file type
| ... | @@ -9,39 +9,58 @@ import UIKit | ... | @@ -9,39 +9,58 @@ import UIKit |
| 9 | 9 | ||
| 10 | extension UIViewController { | 10 | extension UIViewController { |
| 11 | func setBackButton(_ icon:String = "ic_back_2") { | 11 | func setBackButton(_ icon:String = "ic_back_2") { |
| 12 | - let uiscreen: CGRect = UIScreen.main.bounds | 12 | +// let uiscreen: CGRect = UIScreen.main.bounds |
| 13 | 13 | ||
| 14 | - let backButton = UIButton(type: UIButton.ButtonType.custom) as UIButton | 14 | +// let backButton = UIButton(type: UIButton.ButtonType.custom) as UIButton |
| 15 | - if (icon == "ic_close_2") { | 15 | +// if (icon == "ic_close_2") { |
| 16 | - backButton.frame = CGRect(x: 0, y: 0, width: 18, height: 18) | 16 | +// backButton.frame = CGRect(x: 0, y: 0, width: 18, height: 18) |
| 17 | - } else { | 17 | +// } else { |
| 18 | - backButton.frame = CGRect(x: 0, y: 0, width: 18, height: 18) | 18 | +// backButton.frame = CGRect(x: 0, y: 0, width: 18, height: 18) |
| 19 | - } | 19 | +// } |
| 20 | -// backButton.frame = CGRect(x: 0, y: 0, width: uiscreen.height * 0.01, height: uiscreen.height * 0.01) | 20 | +// // backButton.frame = CGRect(x: 0, y: 0, width: uiscreen.height * 0.01, height: uiscreen.height * 0.01) |
| 21 | - // backButton.backgroundColor = .red | 21 | +// // backButton.backgroundColor = .red |
| 22 | - backButton.imageView!.contentMode = .scaleAspectFit | 22 | +// backButton.imageView!.contentMode = .scaleAspectFit |
| 23 | - //backButton.setBackgroundImage(UIImage(named:Assets.Navigation.backButton), for: UIControlState()) | 23 | +// //backButton.setBackgroundImage(UIImage(named:Assets.Navigation.backButton), for: UIControlState()) |
| 24 | -// backButton.setImage(UIImage(named: icon), for: .normal) | 24 | +// // backButton.setImage(UIImage(named: icon), for: .normal) |
| 25 | - backButton.setBackgroundImage(UIImage(named: icon), for: .normal) | 25 | +// backButton.setBackgroundImage(UIImage(named: icon), for: .normal) |
| 26 | -// backButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: -20, bottom: 0, right: 0) | 26 | +// // backButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: -20, bottom: 0, right: 0) |
| 27 | - backButton.addTarget(self, action: #selector(moveToBack(_:)), for: .touchUpInside) | 27 | +// backButton.addTarget(self, action: #selector(moveToBack(_:)), for: .touchUpInside) |
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | - backButton.translatesAutoresizingMaskIntoConstraints = false | 30 | +// backButton.translatesAutoresizingMaskIntoConstraints = false |
| 31 | - // Add width, height constraints | 31 | +// // Add width, height constraints |
| 32 | - if (icon == "ic_close_2") { | 32 | +// if (icon == "ic_close_2") { |
| 33 | - let widthContraints = NSLayoutConstraint(item: backButton, attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: 18) | 33 | +// let widthContraints = NSLayoutConstraint(item: backButton, attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: 18) |
| 34 | - let heightContraints = NSLayoutConstraint(item: backButton, attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: 18) | 34 | +// let heightContraints = NSLayoutConstraint(item: backButton, attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: 18) |
| 35 | - NSLayoutConstraint.activate([heightContraints,widthContraints]) | 35 | +// NSLayoutConstraint.activate([heightContraints,widthContraints]) |
| 36 | - } else { | 36 | +// } else { |
| 37 | - let widthContraints = NSLayoutConstraint(item: backButton, attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: 18) | 37 | +// let widthContraints = NSLayoutConstraint(item: backButton, attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: 18) |
| 38 | - let heightContraints = NSLayoutConstraint(item: backButton, attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: 18) | 38 | +// let heightContraints = NSLayoutConstraint(item: backButton, attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: 18) |
| 39 | - NSLayoutConstraint.activate([heightContraints,widthContraints]) | 39 | +// NSLayoutConstraint.activate([heightContraints,widthContraints]) |
| 40 | - } | 40 | +// } |
| 41 | 41 | ||
| 42 | - let leftBarButtonItem: UIBarButtonItem = UIBarButtonItem(customView: backButton) | 42 | +// let leftBarButtonItem: UIBarButtonItem = UIBarButtonItem(customView: backButton) |
| 43 | - NSLayoutConstraint.activate([(leftBarButtonItem.customView!.widthAnchor.constraint(equalToConstant: 18)),(leftBarButtonItem.customView!.heightAnchor.constraint(equalToConstant: 18))]) | 43 | +// NSLayoutConstraint.activate([(leftBarButtonItem.customView!.widthAnchor.constraint(equalToConstant: 18)),(leftBarButtonItem.customView!.heightAnchor.constraint(equalToConstant: 18))]) |
| 44 | - self.navigationItem.setLeftBarButton(leftBarButtonItem, animated: false) | 44 | +// self.navigationItem.setLeftBarButton(leftBarButtonItem, animated: false) |
| 45 | + | ||
| 46 | + | ||
| 47 | + self.navigationItem.setHidesBackButton(true, animated:false) | ||
| 48 | + | ||
| 49 | + //your custom view for back image with custom size | ||
| 50 | + let view = UIView(frame: CGRect(x: 0, y: 0, width: 40, height: 40)) | ||
| 51 | + let imageView = UIImageView(frame: CGRect(x: 10, y: 10, width: 18, height: 18)) | ||
| 52 | + | ||
| 53 | + if let imgBackArrow = UIImage(named: icon, in: Bundle(for: MyEmptyClass.self), compatibleWith: nil) { | ||
| 54 | + imageView.image = imgBackArrow | ||
| 55 | + } | ||
| 56 | + view.addSubview(imageView) | ||
| 57 | + | ||
| 58 | + let backTap = UITapGestureRecognizer(target: self, action: #selector(moveToBack(_:))) | ||
| 59 | + view.addGestureRecognizer(backTap) | ||
| 60 | + | ||
| 61 | + let leftBarButtonItem = UIBarButtonItem(customView: view ) | ||
| 62 | + self.navigationItem.leftBarButtonItem = leftBarButtonItem | ||
| 63 | + | ||
| 45 | self.navigationItem.title = "" | 64 | self.navigationItem.title = "" |
| 46 | 65 | ||
| 47 | // Add backgroundColor | 66 | // Add backgroundColor | ... | ... |
-
Please register or login to post a comment