let label = UILabel() let attrString = NSMutableAttributedString(string: "Agree to the "User Service Agreement" and "Privacy Policy"") label.frame = CGRect(x: 71, y: 735, width: 256, height: 34) label.numberOfLines = 0 let attr: [NSAttributedString.Key : Any] = [.font: UIFont(name: "PingFang SC-Regular", size: 12),.foregroundColor: UIColor(red: 1, green: 1, blue: 1, alpha: 1)] attrString.addAttributes(attr, range: NSRange(location: 0, length: attrString.length)) view.addSubview(label) let strSubAttr1: [NSMutableAttributedString.Key: Any] = [.font: UIFont(name: "PingFang SC-Regular", size: 12),.foregroundColor: UIColor(red: 1, green: 1, blue: 1,alpha:1)] attrString.addAttributes(strSubAttr1, range: NSRange(location: 0, length: 13)) let strSubAttr2: [NSMutableAttributedString.Key: Any] = [.font: UIFont(name: "PingFang SC-Regular", size: 12),.foregroundColor: UIColor(red: 0.78, green: 0.35, blue: 1,alpha:1)] attrString.addAttributes(strSubAttr2, range: NSRange(location: 13, length: 24)) let strSubAttr3: [NSMutableAttributedString.Key: Any] = [.font: UIFont(name: "PingFang SC-Regular", size: 12),.foregroundColor: UIColor(red: 1, green: 1, blue: 1,alpha:1)] attrString.addAttributes(strSubAttr3, range: NSRange(location: 37, length: 5)) let strSubAttr4: [NSMutableAttributedString.Key: Any] = [.font: UIFont(name: "PingFang SC-Regular", size: 12),.foregroundColor: UIColor(red: 0.78, green: 0.35, blue: 1,alpha:1)] attrString.addAttributes(strSubAttr4, range: NSRange(location: 42, length: 16)) label.attributedText = attrString