overload func VIEwDIDLoad() let tap = UITapGestureRecognizer(target: self,action: #selector(handleTap)) container.addGestureRecognizer(tap)} func handleTap(gesture: UITapGestureRecognizer) { let location = gesture.location(in: gesture.vIEw) startX = location.x startY = location.y drawText(onLayer: vIEw.layer,fromPoint: CGPoint(x: startX,y: startY),topoint: CGPoint(x:location.x,y:location.y))}func drawText(onLayer layer: CALayer,fromPoint start: CGPoint,topoint end:CGPoint) { let myTextLayer = CATextLayer() myTextLayer.string = "Google" myTextLayer.backgroundcolor = UIcolor.black.cgcolor myTextLayer.foregroundcolor = UIcolor.white.cgcolor //myTextLayer.frame = vIEw.bounds let myBounds = CGRect(origin: start,size: CGSize(wIDth: 128,height: 32)) myTextLayer.frame = myBounds layer.addSublayer(myTextLayer)}解决方法 是的,雅虎!
这就是答案!
myTextLayer.preferredFrameSize()总结
以上是内存溢出为你收集整理的ios – 确定CATextLayer中textBox的大小全部内容,希望文章能够帮你解决ios – 确定CATextLayer中textBox的大小所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)