#14從 playground 調色去背圖片

成品:

1.僅更改背景顏色(左圖)

程式碼:

import UIKitlet rimuruImage = UIImage(named: "rimuru.png")let rimuruImageView =  UIImageView(image: rimuruImage)rimuruImageView.backgroundColor = UIColor(red: 1, green: 1, blue: 0, alpha: 0.3)

2.結合星空背景,並更改顏色(右圖)

程式碼:

import UIKitlet rimuruImage = UIImage(named: "rimuru.png")let rimuruImageView =  UIImageView(image: rimuruImage)let starskyImageView = UIImageView(image: UIImage(named: "starsky.jpg"))starskyImageView.frame = rimuruImageView.framestarskyImageView.addSubview(rimuruImageView)rimuruImageView.backgroundColor = UIColor(red:1 , green: 0, blue:1 , alpha: 0.3)starskyImageView

參考資料:

--

--