Tôi muốn tăng độ chênh lệch của bóng trong nhãn UILabel nhưng tôi không thể tìm thấy thuộc tính để làm điều đó. Tôi đã thêm ảnh bên dưới để minh họa sự cố.iOS - Bóng trải trên UILabel
Các Nhãn hàng đầu là hiệu quả mong muốn tôi có thể tạo ra trong Photoshop. Nhãn dưới minh họa các thuộc tính tôi có thể tìm thấy trong iOS. Đây là mã tôi đã sử dụng cho Nhãn dưới cùng.
let bottomLabel = UILabel(frame: CGRectMake(0, 0, maxWidth, 18))
bottomLabel.backgroundColor = UIColor.clearColor()
bottomLabel.textColor = UIColor.whiteColor()
bottomLabel.font = UIFont.boldSystemFontOfSize(16)
bottomLabel.text = title
bottomLabel.textAlignment = .Center
bottomLabel.numberOfLines = 1
bottomLabel.layer.shadowOffset = CGSize(width: 0, height: 0)
bottomLabel.layer.shadowOpacity = 1
bottomLabel.layer.shadowRadius = 2
Tôi đã tìm đề xuất sử dụng nhãn thứ hai làm bóng nhưng điều này không cho kết quả mong muốn. Đây là mã cho Nhãn đó.
let bottomLabelShadow = UILabel(frame: CGRectMake(0, 1, maxWidth, 18))
bottomLabelShadow.backgroundColor = UIColor.clearColor()
bottomLabelShadow.textColor = UIColor.blackColor()
bottomLabelShadow.font = UIFont.boldSystemFontOfSize(16)
bottomLabelShadow.text = title
bottomLabelShadow.textAlignment = .Center
bottomLabelShadow.numberOfLines = 1
bottomLabelShadow.layer.shadowOffset = CGSize(width: 0, height: 0)
bottomLabelShadow.layer.shadowOpacity = 1
bottomLabelShadow.layer.shadowRadius = 2
Trên thực tế có một bài viết tốt về bóng https://makeapppie.com/2015/05/19/swift-swift-how-to-make-a-drop-shadow-in-user-interfaces/ –