作業#4使用圖片,文字,emoji,邊框 & 圓角製作漂亮卡片

先來看看我女朋友妹妹養兩隻可愛的肥貓,看著貓咪當文青寫程式心情都變好了。

附上程式碼

import UIKitlet cattImageView = UIImageView(image: UIImage(named: "Snow.png"))
cattImageView.backgroundColor = UIColor(red: 1, green: 1, blue: 0, alpha: 1)
cattImageView.frame = CGRect(x: 0, y: 0, width: 500, height: 500)let messageLabel = UILabel(frame: CGRect(x: 150, y:100, width: 200, height: 50))
messageLabel.text = "凹嗚凹嗚凹嗚"
messageLabel.textColor = UIColor(red: 1, green: 69/255, blue: 0, alpha: 1)
messageLabel.font = UIFont.systemFont(ofSize: 30)
cattImageView.addSubview(messageLabel)
cattImageView.layer.borderColor = CGColor(red: 210/255, green: 105/255, blue: 30/255, alpha: 1)
cattImageView.layer.borderWidth = CGFloat(10)
cattImageView
cattImageView.layer.cornerRadius = 50
cattImageView.clipsToBounds = true
cattImageView
var heartLabel = UILabel(frame: CGRect(x: 20, y: 20, width: 100, height: 25))
heartLabel.text = "♥️"
heartLabel.font = UIFont.systemFont(ofSize: 25)
cattImageView.addSubview(heartLabel)
heartLabel = UILabel(frame: CGRect(x:450, y: 20, width: 100, height: 25))
heartLabel.text = "🧡"
heartLabel.font = UIFont.systemFont(ofSize: 25)
cattImageView.addSubview(heartLabel)
heartLabel = UILabel(frame: CGRect(x: 450, y: 450, width: 100, height: 25))
heartLabel.text = "💜"
heartLabel.font = UIFont.systemFont(ofSize: 25)
cattImageView.addSubview(heartLabel)
heartLabel = UILabel(frame: CGRect(x: 20, y: 450, width: 100, height: 25))
heartLabel.text = "💙"
heartLabel.font = UIFont.systemFont(ofSize: 25)
cattImageView.addSubview(heartLabel)
heartLabel.transform = CGAffineTransform(rotationAngle: .pi / 180 * 30)
cattImageView

--

--