for index in 0..<4 {
let i = (Int)(arc4random()) % (codeArray.count-1)
let str = codeArray[i]
if index == 0 {
codeStr = str as NSString
}else {
codeStr = "\(codeStr)\(str)" as NSString
}
}
for i in 0..<codeStr.length {
let pxx = arc4random() % UInt32(randWidth)
let px = CGFloat(pxx) + CGFloat(i)*(self.frame.size.width-3)/CGFloat(codeStr.length)
let py = arc4random() % UInt32(randHeight)
let label = UILabel.init(frame: CGRect.init(x: px + 3, y: CGFloat(py), width: textSize.width, height: textSize.height))
label.text = String.init(format: "%C", codeStr.character(at: i))
label.font = UIFont.systemFont(ofSize: 20)
if (isRotation == true) {
let a = arc4random() % UInt32(60)
let r = Double(a)-30
label.transform = CGAffineTransform.init(rotationAngle: CGFloat(r*M_PI)/180)
}
bgView.addSubview(label)
}
for _ in 0...9 {
let path = UIBezierPath.init()
let pX = arc4random() % UInt32(self.frame.width)
let pY = arc4random() % UInt32(self.frame.height)
path.move(to: CGPoint.init(x: CGFloat(pX), y: CGFloat(pY)))
let ptX = arc4random() % UInt32(self.frame.width)
let ptY = arc4random() % UInt32(self.frame.height)
path.addLine(to: CGPoint.init(x: CGFloat(ptX), y: CGFloat(ptY)))
let layer = CAShapeLayer.init()
layer.strokeColor = UIColor.getRandomColor(withAlpha: 0.2).cgColor//layer的边框色
layer.lineWidth = 1.0
layer.strokeEnd = 1
layer.fillColor = UIColor.clear.cgColor
layer.path = path.cgPath
bgView.layer.addSublayer(layer)
}
public func refreshCode(callBack: @escaping (_ str: NSString) -> ()) {
initCodeView()
callBack(codeStr)
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有