ziyu
彼得潘的 Swift iOS / Flutter App 開發教室
3 min readMar 23, 2022

--

三、使用圖片,文字,emoji,邊框 & 圓角製作漂亮卡片

目的:使用Xcode playground 製作卡片

成品:

程式碼:

import UIKit//顯示圖片let girlImageView = UIImageView(image: UIImage(named: "girl.png"))//設定圖片大小girlImageView.frame = CGRect(x: 0, y: 0, width: 300, height: 300)//設定邊框girlImageView.layer.borderWidth = 5//設定邊框圓角girlImageView.layer.cornerRadius = 30girlImageView.clipsToBounds = true//使用迴圈製作邊框🌼for i in 0...5 {let flowerLabel = UILabel(frame: CGRect(x: 45+i*35, y: 10, width: 40, height: 40))flowerLabel.text = "🌼"flowerLabel.font = UIFont.systemFont(ofSize: 25)girlImageView.addSubview(flowerLabel)}for i in 0...5 {let flowerLabel = UILabel(frame: CGRect(x: 45+i*35, y: 260, width: 40, height: 40))flowerLabel.text = "🌼"flowerLabel.font = UIFont.systemFont(ofSize: 25)girlImageView.addSubview(flowerLabel)}for i in 0...5 {let flowerLabel = UILabel(frame: CGRect(x: 10, y: 45+i*35, width: 40, height: 40))flowerLabel.text = "🌼"flowerLabel.font = UIFont.systemFont(ofSize: 25)girlImageView.addSubview(flowerLabel)}for i in 0...5 {let flowerLabel = UILabel(frame: CGRect(x: 250, y: 45+i*35, width: 40, height: 40))flowerLabel.text = "🌼"flowerLabel.font = UIFont.systemFont(ofSize: 25)girlImageView.addSubview(flowerLabel)}

參考資料:

--

--