[iOS swift UIKit] UIView 배경색 랜덤으로 변경하기
import UIKit
class MovieCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var backView: UIView!
func configureCell(data: Movie) {
let backgroundColor: [UIColor] = [.yellow, .systemPink, .lightGray]
backView.backgroundColor = backgroundColor.randomElement()
}
}
'iOS > iOS Swift 개발 일기' 카테고리의 다른 글
데이터베이스 CRUD (0) | 2022.08.23 |
---|---|
[iOS swift] actionsheet 액션시트 만들기 (0) | 2022.08.23 |
expected declaration 오류 뜰 때 (0) | 2022.07.21 |
iOS swift 반환타입 알아내기 (0) | 2022.07.16 |
iOS swift DateFormatter (0) | 2022.07.15 |