Just send this answer for reference, as the user has already received the answer. Try this code in Swift and let me know how this happens.
func buttomBorder(label: UILabel) -> UILabel { // For Buttom Border let frame = label.frame let bottomLayer = CALayer() bottomLayer.frame = CGRect(x: 0, y: frame.height - 1, width: frame.width - 2, height: 1) bottomLayer.backgroundColor = UIColor.lightGray.cgColor label.layer.addSublayer(bottomLayer) //For Shadow label.layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.25).CGColor label.layer.shadowOffset = CGSizeMake(0.0, 2.0) label.layer.shadowOpacity = 1.0 label.layer.shadowRadius = 0.0 label.layer.masksToBounds = false label.layer.cornerRadius = 4.0 return label }
Function call:
labelName = buttomBoder(label: labelName)
source share