Skip to content

Woozzang/ios-project-led_board

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LED-Board

μž…λ ₯ν•œ ν…μŠ€νŠΈλ₯Ό μ „κ΄‘νŒ 화면에 λ³΄μ—¬μ£ΌλŠ” μ•± 🌱 (SSAC 과제 ν”„λ‘œμ νŠΈ)

1


μ‚¬μš© κ°œλ… : UITextField, FirstResponder, UIButton, TapGestureRecognizer, Delegation, Target-Action, UIScrollview

1단계

βœ… iOS Version, Device Orientation μ„€μ •

βœ… AppIcon 적용

β†’ λ¦¬μ†ŒμŠ€ 이미지가 단일 ν•΄μƒλ„λ§Œ μ „λ‹¬λ˜μ–΄μ„œ 이 링크 μ—μ„œ 해상도별 μ•„μ΄μ½˜μ„ μƒμ„±ν•΄μ„œ λ„£μ–΄μ£Όμ—ˆλ‹€.

βœ… LaunchScreen

  • 이미지 μΆ”κ°€
  • 3μ΄ˆκ°„ κ°•μ œλ‘œ λ³΄μ—¬μ£ΌλŠ” 둜직 λ„£μ–΄μ£ΌκΈ°

βœ… Xcode12 μ—μ„œλŠ” μ•ˆλ˜λŠ” padding λ„£κΈ° 직접 κ΅¬ν˜„

β†’ IntrinsicContentSize λŒ€μ‹  Autolayout μ œμ•½μ„ μ‚¬μš©ν•œλ‹€λ©΄ contentInset 으둜 ν•΄κ²°ν•˜λ©΄ 될 것 κ°™λ‹€.

β†’ μ•± ꡬ성이 ν™”λ©΄ ν•˜λ‚˜λΏμ΄λΌμ„œ νŽΈμ˜μƒ UIButton 을 λ”°λ‘œ μ„œλΈŒν΄λž˜μ‹±ν•΄μ„œ μ‚¬μš©ν•˜μ§€ μ•Šμ•˜λ‹€.

 extension UIButton {
  
  private var customDefinedHorizontalPadding: CGFloat {
    get {
      return 24
    }
  }
  
  open override var intrinsicContentSize: CGSize {
  
    get {
      let baseSize = super.intrinsicContentSize
      
      return CGSize(width: baseSize.width + (customDefinedHorizontalPadding * 2),
                    height: baseSize.height)
    }
  }
}

βœ… 기본적인 ν™”λ©΄ ꡬ성


2단계

βœ… Outlet μ—°κ²° ν›„, μ½”λ“œλ‘œ UI μˆ˜μ •

β†’ didSet 에 μ»€μŠ€ν…€λ©”μ„œλ“œ 호좜

@IBOutlet weak var boardView: UIView! {
    didSet {
      applyRoundDesign(to: boardView)
    }
}

...

private func applyRoundDesign(to view: UIView) {
    view.layer.cornerRadius = view.frame.height/4
    view.layer.borderColor = UIColor.black.cgColor
    view.layer.borderWidth = 1
}

βœ… Button Action 에 TextField 의 Text λ³€κ²½ 둜직 μΆ”κ°€

βœ… Aa Button 을 ν΄λ¦­ν•˜λ©΄, Label 의 ν…μŠ€νŠΈμ»¬λŸ¬κ°€ 랜덀으둜 λ³€ν™”

@IBAction func didTapColorButton(_ sender: Any) {
    
    let redValue : CGFloat = CGFloat((1...256).randomElement()!) / CGFloat(256)
    let greenValue : CGFloat = CGFloat((1...256).randomElement()!) / CGFloat(256)
    let blueVlaue: CGFloat = CGFloat((1...256).randomElement()!) / CGFloat(256)
    
    let randomColor = UIColor(red: redValue, green: greenValue, blue: blueVlaue, alpha: 1)
    
    
    resultLabel.textColor = randomColor
}

3단계

βœ… νƒ­ μ œμŠ€μ³κ°€ μ‹€ν–‰λ˜λ©΄ ν‚€λ³΄λ“œλ₯Ό λ‚΄λ €μ£ΌκΈ°

β†’ TapGestureRecognizer λŠ” RootView 에 μΆ”κ°€ν•΄μ£Όμ—ˆκ³ , μ•‘μ…˜μ„ μ—°κ²°ν•˜μ—¬ resignFristResponder() λ₯Ό ν˜ΈμΆœν•΄μ£Όμ—ˆλ‹€.

4단계

βœ… ν‚€λ³΄λ“œ 리턴킀λ₯Ό λˆ„λ₯΄λ©΄ ν‚€λ³΄λ“œκ°€ λ‚΄λ €κ°€κ²Œ κ΅¬ν˜„ν•˜κΈ°

β†’ 리턴 ν‚€λ₯Ό λˆ„λ₯΄λ©΄ Did End On Exit λ©”μ‹œμ§€κ°€ μ „λ‹¬λœλ‹€. 이것을 μ²˜λ¦¬ν•  μ•‘μ…˜μ„ κ΅¬ν˜„ν•˜λ©΄ λœλ‹€.

β†’ λ‹€λ₯Έ λ°©λ²•μœΌλ‘œ UITextFieldDelegate 쀑에도 κ΄€λ ¨ λ©”μ„œλ“œκ°€ μžˆμ„κΉŒ?? 있음

func textFieldShouldReturn(_ textField: UITextField) -> Bool {
    resultLabel.text = textField.text
    textField.resignFirstResponder()
    return true
}

5단계

βœ… νƒ­ 제슀처λ₯Ό 클릭씨 상단 View κ°€ ν† κΈ€ ν˜•νƒœλ‘œ μˆ¨κ²Όλ‹€ λ³΄μ˜€λ‹€ ν•˜λŠ” κΈ°λŠ₯을 κ΅¬ν˜„

βœ… κΈ€μžμˆ˜κ°€ λ§Žμ•„μ§€λ©΄ μžλ™μœΌλ‘œ 슀크둀 되게 κ΅¬ν˜„

β†’ 기쑴의 슀크둀뷰 κΈ°μ‘΄ 섀정은 κ·ΈλŒ€λ‘œ 진행

β†’ UILabel κ³Ό 슀크둀뷰의 컨텐츠 λ£¨νŠΈλ·°μ— μŠ€νŽ˜μ΄μ‹± μ œμ•½μ„ κ±Έκ³ , μƒμœ„λ·°μ˜ width μ œμ•½μ„ equltTo μ—μ„œ greaterThan 으둜 λ°”κΏ”μ£Όλ©΄ λ™μ μœΌλ‘œ μ¦κ°€ν•œλ‹Ή!
Untitled

About

LED μ „κ΄‘νŒ μ•±πŸš¦

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages