#20 How ? UI Kit 畫出情人節卡片
利用 Xcode Playground 製作美美的小卡片
Published in
Aug 5, 2022
不囉唆,先上圖:
提幾個寫程式的時候要注意的點:
(1)設定邊框記得要將超出的部分裁切掉,並且設定好 layer.borderWidth
catImage.layer.borderColor = CGColor(red: 1, green: 181/255, blue: 197/255, alpha: 1)catImage.layer.borderWidth=5catImage.clipsToBounds=true
(2)Label 的文字設定:(有兩種方法)
系統字體法:
messageLabel.font = UIFont.systemFont(ofSize:25)
或者 直接設定法:
messageLabel.font = messageLabel.font.withSize(36)
(3)旋轉角度:
starLabel.transform = CGAffineTransform(rotationAngle: .pi/180 * 30)
附上程式碼:
附上 Github: