[TIL] Swift - cornerRadius, UIFont.boldSystemFont(ofSize:), UIImage(named: )

신승현·2024년 2월 26일

TIL

목록 보기
29/72

1. cornerRadius

  • UIKit을 사용하면서, UI의 모서리를 둥글게 하고 싶을 때 사용한다.
profileCard.layer.cornerRadius = 30; // View의 모서리를 30만큼 둥글게
image.layer.cornerRadius = 30; // UIImageView의 모서리를 30만큼 둥글게

2. UIFont.boldSystemFont(ofSize: )

  • UILabel의 텍스트를 굵게 나타내려면 boldSystemFont()를 사용하면 된다.
name.font = UIFont.boldSystemFont(ofSize: 32); // UILabel의 텍스트 크기와 굵기를 32로 설정

3. UIImage(named: )

  • UIImageView에 직접적으로 이미지를 넣을 수도 있지만, 나는 Assets에서 ImageSet을 추가해서 페이지가 열릴 때 이미지를 불러오도록 작성했다.
image.image = UIImage(named: "Image"); // UIImageView에 "Image"라는 이름의 ImageSet을 설정한다.
profile
개발자

0개의 댓글