CALayer使用的简单例子 - 也许在一个UITextField [英] Simple example of CALayer usage -- perhaps in a UITextField
问题描述
我需要为包含多个UITextField的Cocoa Touch数据输入屏幕实现自定义键盘。我已经构建了键盘,一切正常工作,除了现在我需要弄清楚如何实现闪烁的光标。 (当禁用UITextField的内置键盘时,也会丢失游标)。在googling中,我已经看到了一些使用CALayer动画来做到这一点。但是,我还没有找到一个简单的例子,我将如何实现这一点。因为UITextField继承自UIView,我希望我可以使用文本字段视图作为主机层。眨眼的动画部分不是令我担心的,它只是正确设置。任何建议,或指向其他网站包含一个简单的教程? (我发现的一切都是面向多层和游戏,而不是建立在一个基本的视图/文本字段之上)。
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).
推荐答案
你不得不基本上循环一个黑色CAlayer的opacity属性的动画从0到1重复,但现在你有自定义输入视图 https://developer.apple.com/iphone/library/documentation/ General / Conceptual / iPadProgrammingGuide / Text / Text.html#// apple_ref / doc / uid / TP40009370-CH8
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
这篇关于CALayer使用的简单例子 - 也许在一个UITextField的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!