Issue while assigning UITextView frame to CATextLayer

120 Views Asked by At

I'm retrieving subviews(UITextView) from the UIImageView and with the content of the UITextView I'm creating CATextLayer to add in the video file because I need to show each frame for a particular timeframe. I was able to copy most of the attributes of UITextView except its frame.

for subview in tempImageView.subviews {          
    let textview : UITextView
    textview = subview as! UITextView
    let text = CATextLayer()
    text.frame = textview.frame
    print(text.frame)
    text.string = textview.text
    text.font = textview.font
    text.foregroundColor = textview.textColor?.cgColor 
    text.backgroundColor = textview.backgroundColor?.cgColor
    text.displayIfNeeded()
    text.beginTime = 3
    text.duration = 2    
    parentlayer.addSublayer(text)                
}
0

There are 0 best solutions below