Skip to content

Latest commit

 

History

History
79 lines (63 loc) · 2.67 KB

README_Week1.md

File metadata and controls

79 lines (63 loc) · 2.67 KB

week 1

B101

과제 동영상 📎



구현 과정 🛠

✔️ 모서리가 둥근 Button

    extension UIButton{
    func setBackgroundColor(_ color: UIColor, for state: UIControl.State) {
            UIGraphicsBeginImageContext(CGSize(width: 1.0, height: 1.0))
            guard let context = UIGraphicsGetCurrentContext() else { return }
            context.setFillColor(color.cgColor)
            context.fill(CGRect(x: 0.0, y: 0.0, width: 1.0, height: 1.0))
            
            let backgroundImage = UIGraphicsGetImageFromCurrentImageContext()
            UIGraphicsEndImageContext()
             
            self.setBackgroundImage(backgroundImage, for: state)
        }
    
    func setRoundCorner(_ radius : CGFloat){
        self.layer.masksToBounds = true
        self.layer.cornerRadius = radius
    }
}


✔️ TextField 밑줄

✔️ TextField Place Holder 속성값 변경하기

extension UITextField {
    func setBottomBorder() {
      self.borderStyle            = .none
      self.layer.backgroundColor  = UIColor.white.cgColor
      self.layer.masksToBounds    = false
      self.layer.shadowColor      = UIColor.gray500.cgColor
      self.layer.shadowOffset     = CGSize(width: 0.0, height: 1.0)
      self.layer.shadowOpacity    = 0.8
      self.layer.shadowRadius     = 0.0

    }
  
  func setPlaceHolder(_ text : String, _ color : UIColor, _ font : UIFont) {
      self.attributedPlaceholder = NSAttributedString(string: "\(text)", attributes: [NSAttributedString.Key.foregroundColor : color,NSAttributedString.Key.font : font])
  }
}


✔️ Then 라이브러리 없이 then 사용 하기

  extension UIView : Then {}

public protocol Then {}

extension Then where Self  : Any {
    public func then(_ block: (Self) throws -> Void) rethrows {
        try block(self)
    }
}