Notice
Recent Posts
Recent Comments
Link
ยซ   2024/05   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
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 31
Archives
Today
Total
๊ด€๋ฆฌ ๋ฉ”๋‰ด

lgvv98

[RxSwfit] ํ…Œ์ด๋ธ” ๋ทฐ ์•ˆ์— ๋ฒ„ํŠผ์ด ๋ฐ˜์‘ํ•˜์ง€ ์•Š์„ ๋•Œ ๋ณธ๋ฌธ

iOSํ”„๋กœ์ ํŠธ/๐Ÿชท ๋‘๊ตฟํ•ด์ปคํ†ค(HappyHouse)

[RxSwfit] ํ…Œ์ด๋ธ” ๋ทฐ ์•ˆ์— ๋ฒ„ํŠผ์ด ๋ฐ˜์‘ํ•˜์ง€ ์•Š์„ ๋•Œ

๐Ÿฅ• ์บ๋Ÿฟ๋งจ 2021. 9. 17. 17:07

โœ… ์ด๋ฒˆ ์‹œ๊ฐ„์—๋Š” TableView์•ˆ์— UIButton์ด ๋ฐ˜์‘ํ•˜์ง€ ์•Š์„ ๋•Œ๋ฅผ ์•Œ์•„๋ณด์ž.

ํ…Œ์ด๋ธ” ๋ทฐ ์•ˆ์˜ ์…€

 

์ €๊ธฐ ๋ณด์ด๋Š” ์ˆ˜์ •ํ•˜๊ธฐ์™€ ์ฑŒ๋ฆฐ์ง€ ์‹œ์ž‘์ด UIButton์ด๋‹ค.

IBAction์œผ๋กœ ์—ฐ๊ฒฐํ•˜๋‹ˆ๊นŒ ์ž˜ ๋˜๋Š”๋ฐ, rx๋ฅผ ์‚ฌ์šฉํ•˜๋‹ˆ๊นŒ ์•ˆ๋˜๋Š” ๋ฌธ์ œ ๋ฐœ๊ฒฌ

 

์•„๋ž˜์˜ ์ฝ”๋“œ๋ฅผ ๋ณด๋ฉด ์‰ฝ๊ฒŒ ๋ฌธ์ œ ํ•ด๊ฒฐ์„ ๋ฐฉ๋ฒ•์„ ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋‹ค.

 

// ์ฒ˜์Œ์— ์ž‘์„ฑํ•œ ์ฝ”๋“œ -> ๋ฐ˜์‘ ์—†์Œ
     REditButton.rx.tap
            .subscribe {
                self.REditButton.tintColor = .blue
                self.REditButton.setTitle("  ๋„์ „์ค‘...  ", for: .normal)
            }

// ๋‘๋ฒˆ์งธ๋กœ ์ž‘์„ฑํ•œ ์ฝ”๋“œ -> ์—ฌ์ „ํžˆ ๋ฐ˜์‘ ์—†์Œ
     REditButton.rx.controlEvent(.allTouchEvents)
            .subscribe {
                self.REditButton.tintColor = .blue
                self.REditButton.setTitle("  ๋„์ „์ค‘...  ", for: .normal)
            }
            
// ์„ธ๋ฒˆ์งธ๋กœ ์ž‘์„ฑํ•œ ์ฝ”๋“œ -> ๋ฐ˜์‘ ok
     REditButton.rx.tap
            .bind {
                self.REditButton.tintColor = .blue
                self.REditButton.setTitle("  ๋„์ „์ค‘...  ", for: .normal)
            }
            
// ๋ฒˆ์™ธ   
     REditButton.rx.controlEvent(.allTouchEvents)
            .subscribe {
                self.REditButton.tintColor = .blue
                self.REditButton.setTitle("  ๋„์ „์ค‘...  ", for: .normal)
            }

 

 

๐ŸŸ  ๊ฒฐ๋ก  

subscribe๋ฅผ bind๋กœ ๋ฐ”๊ฟ”์ฃผ์–ด์•ผ ํ•œ๋‹ค. 

Comments