Simple example of CALayer usage — perhaps in a UITextField

孤街醉人 提交于 2019-12-10 19:01:45

问题


I have an requirement to implement a custom keyboard for a Cocoa Touch data entry screen containing multiple UITextFields. I've built the keyboard, and everything is working except now I need to figure out how to implement a blinking cursor. (When you disable the UITextField's built-in keyboard, you lose the cursor as well). In googling around, I've seen a few mentions of using CALayer animation to do this. However, I have not yet found a simple example of how I might implement this. Since UITextField inherits from UIView, I was hoping I could use the text fields view as the host layer. The animation part of the blink is not what is worrying me, it is just setting this up properly. Any advice, or pointers to other sites containing a simple tutorial? (everything I've found has been oriented toward multi-layers and games, and not built on top of a basic view/textfield).


回答1:


You would have had to basically cycle a animation of a black CAlayer's opacity property from 0 to 1 repeatedly, but now you have custom input views https://developer.apple.com/iphone/library/documentation/General/Conceptual/iPadProgrammingGuide/Text/Text.html#//apple_ref/doc/uid/TP40009370-CH8



来源:https://stackoverflow.com/questions/2238746/simple-example-of-calayer-usage-perhaps-in-a-uitextfield

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!