기어가더라도 제대로
20220703 TIL 본문
앞으로 더 공부할 주제입니다. 초안만 작성해서 띄워 놓습니다. 혹시 의견이 있으시면 덧글로 남겨주세요.
lazy var 로 만든 버튼과 let 으로 만든 버튼의 차이
전자는 버튼이 액션과 연결이 되었는데, 후자는 버튼이 액션과 연결되지 않았다. 그 이유는 무엇일까?
//MARK: - 액션이 작동함
private lazy var selectButton: UIBarButtonItem = {
// 코드 ~
}()
//MARK: - 액션이 작동하지 않음
private let selectButton: UIBarButtonItem = {
// 코드 ~
}()
UIButton으로 UIBarButtonItem 을 만드는 방법
private lazy var filterButton: UIBarButtonItem = {
let button = UIButton()
button.setImage(UIImage(named: "filterIcon"), for: .normal)
button.frame = CGRect(x: 0, y: 0, width: 70, height: 30)
button.setTitle("필터", for: .normal)
button.setTitleColor(.systemBlue, for: .normal)
button.titleEdgeInsets = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 0)
button.addTarget(self, action: #selector(filterButtonPressed(_:)), for: .touchUpInside)
let barbutton = UIBarButtonItem(customView: button)
return barbutton
}()
'기타' 카테고리의 다른 글
String을 StaticString 으로 전환하는 방법 (0) | 2022.07.06 |
---|---|
이모지를 xcode 에서 이름 알려주는 프로그램 (0) | 2022.06.30 |
HTTP Accept type header 와 Content-Type header 의 차이점 (7) | 2022.06.16 |
홈 커밍 데이 (0) | 2022.06.05 |
220530 TIL (0) | 2022.05.30 |
Comments