개발/SwiftUI

How to adjust the opacity of a view

까칠코더 2019. 11. 27. 13:10
반응형

 

Hacking with Swift 사이트의 강좌 번역본입니다.

 

[원문 : https://www.hackingwithswift.com/quick-start/swiftui/how-to-adjust-the-opacity-of-a-view]

 

How to adjust the opacity of a view

 

모든 SwiftUI 뷰는 opacity() modifier를 사용해서 부분적이나 전체적인 투명도를 조정할 수 있습니다. 0(완전히 보이지 않음)과 1(완전이 불투명함)사이의 값을 받고, UIKit에서의 UIView alpha 프로퍼티와 같습니다.

 

예를들어, 다음은 빨간색 배경인 텍스트 뷰를 만들고 불투명도를 50%를 주었습니다.

Text("Now you see me")
    .padding()
    .background(Color.red)
    .opacity(0.3)

 

반응형