Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

아울렛 객체로 [UIView] 만들기 #67

Closed
Youngminah opened this issue Oct 29, 2021 · 2 comments
Closed

아울렛 객체로 [UIView] 만들기 #67

Youngminah opened this issue Oct 29, 2021 · 2 comments

Comments

@Youngminah
Copy link
Owner

Youngminah commented Oct 29, 2021

아울렛 객체 컬렉션 만들기

@IBOutlet var collectionLabel: [UILabel]! 
  • 위처럼 선언이 가능하다.
  • weak로는 선언 불가능하다고 오류 뜸 왜지? (밑에 답글 참고)
collectionLabel.forEach { $0.setBorderStyle() }

UILabel + Extension

import UIKit.UILabel

extension UILabel {
    func setBorderStyle() {
        self.backgroundColor = .systemTeal
        self.clipsToBounds = true
        self.layer.borderWidth = 1
        self.layer.cornerRadius = 10
    }
}
  • 위의 코드의 장점
@Youngminah
Copy link
Owner Author

  • 이걸 여태까지 모르고 있었음.. ㅠㅠ

@Youngminah Youngminah changed the title [UIView] 만들기 아울렛 객체로 [UIView] 만들기 Oct 29, 2021
@Youngminah Youngminah added the iOS label Oct 29, 2021
@Youngminah
Copy link
Owner Author

Youngminah commented Oct 29, 2021

IBOutletCollection은 weak로는 선언이 불가능함

  • Outlet 하나는 class 참조 타입으로 선언이 되어있는데,
  • OutletCollection의 컬렉션 형태로 만들면 구조체 타입이 된다.
  • 따라서 구조체 타입이라 weak선언을 붙일 수 없다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant