๐ iOS/UI
[iOS/UI] ๋ค๋น๊ฒ์ด์ ๋ฐ ๋ฐฑ๋ฒํผ ์ปค์คํ ํ๊ธฐ(UINavigationBarItem Custom)
Fomagran ๐ป
2020. 2. 28. 15:18
728x90
๋ฐ์ํ
ํน์ ๋ค๋น๊ฒ์ด์ ์ปจํธ๋กค๋ฌ์์ ํ๋ฉด์ ์ด๋ํ ๋ ์๋์ผ๋ก ๋ฐฑ๋ฒํผ์ด ์๊ธฐ๋ ๊ฒ์ ๋ณผ ์ ์๋๋ฐ
๋๋ ๋ด๊ฐ ์ํ๋ ์์ด์ฝ์ผ๋ก ๋์ฐ๊ณ ๋ฐฑ๋ฒํผ๊ณผ ๋๊ฐ์ ๊ธฐ๋ฅ์ ๊ฐ์ถ๊ฒ ํ๊ณ ์ถ์๋ค.
๋ฐ๋ฒํผ์์ดํ ์์ ์์ ์ด ์ํ๋ ์ด๋ฏธ์ง์ style tagget action์ ๋ง๋ค์ด์ค ๋ค
๋ค๋น๊ฒ์ด์ ์์ดํ ์์ ์ผ์ชฝ ๋ฐ๋ฒํผ ์์ดํ ์ ๋ง๋ค์ด ์ค ๋ฐ๋ฒํผ ์์ดํ ์ ์ค์ ํด์ค๋ค.
1
2
|
let backbutton = UIBarButtonItem(image: UIImage(named: "passwordOn@3x.png"), style: .done, target: self, action: #selector(back))
self.navigationItem.leftBarButtonItem = backbutton
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
action์ #selector(@objc)์ ๋ฃ์ด์ค๋ค.
๋ค๋น๊ฒ์ด์ ์์ ๊ทธ ์ ํ๋ฉด์ผ๋ก ์ด๋ํ๊ฒ ํ๋ @objcํจ์
1
2
3
|
@objc func back() {
self.navigationController?.popViewController(animated: true)
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
์๋์ ๊ฐ์ด ์ค์ ํ ์ด๋ฏธ์ง๋ก ๋ฐฑ๋ฒํผ ์์ดํ ์ด ์์ฑ๋๊ณ ๋๋ฅด๋ฉด ๋ค์ ์ ํ๋ฉด์ผ๋ก ๋์๊ฐ๋ ๊ฒ์ ๋ณผ ์ ์๋ค.
728x90
๋ฐ์ํ