Image View

Lena·2021년 7월 22일
0

iOS앱개발 입문기

목록 보기
4/17

image view

가득채우기

content mode >
1) aspect fill : 그대로
2) scale to fill : stretched (글자의 경우 비추)
3) aspect fill : 전체 비율 유지 하면서 가득 채우기

image view size 변경

: size inspector 에서 width, height 변경할 것

  • Camel Case

IB outlet

  1. 이미지를 편집할 코드 위쪽 빈공간을 정하고
  2. storyboard 에서 원하는 이미지를 선택한 후 Ctrl + click + drag to view controller!
  3. 원하는 이름으로 변경 (이후 코드에서 사용할 변수명)

image 변경하기

Who.What = Value
diceImageView1.image = #imageLiteral

imageLiteral 을 입력하면 해당 프로젝트에서 가지고 있는 이미지 파일을 선택할 수 있음.

** override func viewDidLoad() {Code goes here}

challenge

  1. change the opacity of the dice 1 by using the code.
  2. change the image DiceOne to Dice 2 by using the code
    override func viewDidLoad() {
        super.viewDidLoad()
        
        diceImageView1.image = #imageLiteral(resourceName: "DiceSix") 
        diceImageView1.alpha = 0.5
    }


(왼쪽은 스토리보드 / 오른쪽은 빌드했을 때)

0개의 댓글