f2cf74c7
yangbin
1.0.20(4)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
//
// BackButton.swift
// Twear
//
// Created by yangbin on 2021/11/16.
//
import UIKit
/// 导航栏左侧返回按钮
class BackButton: UIButton {
init(target: Any, action: Selector) {
super.init(frame: CGRect(x: 0, y: 0, width: 22, height: 36))
commonInit(target: target, action: action)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func commonInit(target: Any, action: Selector) {
self.adjustsImageWhenHighlighted = false
self.setImage(UIImage(named: "nav_back"), for: UIControl.State.normal)
self.setImage(UIImage(named: "nav_back"), for: UIControl.State.highlighted)
self.imageView?.contentMode = UIView.ContentMode.scaleAspectFit
self.imageEdgeInsets = UIEdgeInsets(top: 0, left: -(self.frame.size.width > 20 ? self.frame.size.width - 20 : self.frame.size.width), bottom: 0, right:0)
self.addTarget(target, action: action, for: .touchUpInside)
}
}
|