๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐ŸŽ iOS/UI

[iOS/UI] UIButton ์œ„์—๋งŒ ๋‘ฅ๊ธ€๊ฒŒ ํ•˜๊ธฐ

by Fomagran ๐Ÿ’ป 2019. 12. 26.
728x90
๋ฐ˜์‘ํ˜•
//์ต์Šคํ…์…˜์„ ์„ค์ •ํ•ด์ฃผ๊ณ 
extension UIButton {
   func roundedButton(){
    clipsToBounds = true //๋ทฐ์˜ ํ…Œ๋‘๋ฆฌ ๊ธฐ์ค€์œผ๋กœ ์งค๋ฆฌ๊ฒŒ ๋œ๋‹ค.
    layer.cornerRadius = 10 //์–ผ๋งŒํผ ๋‘ฅ๊ธ€๊ฒŒ
    layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner] //์ œ์ผ ์™ผ์ชฝ์œ„์—์„œ ์ œ์ผ ์˜ค๋ฅธ์ชฝ ์œ„๊นŒ์ง€ ๋‘ฅ๊ธ€๊ฒŒ
  // ์•„๋ž˜๋Š” ๋ฒ„ํŠผ์˜ ๋ณด๋”๋ฅผ ์ •ํ•ด์ฃผ๋Š”๊ฒƒ
  //  layer.borderWidth = 1
  //  layer.borderColor = UIColor(displayP3Red: 211/255, green: 211/255, blue: 211/255, alpha: 1).cgColor
     
   }
}

 override func viewDidLoad() {
        super.viewDidLoad()	
		button.roundedButton() //ํ•จ์ˆ˜๋ฅผ ๋ถˆ๋Ÿฌ์˜ค๋ฉด ์‹คํ–‰์ด ๋œ๋‹ค.
        }
        

์•„๋ž˜์™€ ๊ฐ™์ด ์œ„์—๋งŒ ๋‘ฅ๊ธ€๊ฒŒ ์„ค์ •์ด๋œ๋‹ค.

 

728x90
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€