XFAssistiveTouch
XFAssistiveTouch copied to clipboard
Add title for items?
Hi there, Thanks for your code. This is exactly what I want to be in my application. But I have a question... In my case, I wanna put title for all item in AssistiveTouch. How I can custom your code to add an UILabel into it? Please answer me. Thanks in advance..
You can override the XFATItemView, add an UILabel. Then write in the XFAssistiveTouchDelegate "viewController:itemViewAtPosition:" method like this:
- (XFATItemView *)viewController:(XFATViewController *)viewController itemViewAtPosition:(XFATPosition *)position {
switch (position.index) {
case 0:
return [MyATItemView itemWithTitle:"My Title" image:[UIImage imageNamed:@"m2"]]; // Your own initialization
}
}
You can refer to the Landscape Example in "Examples/Landscape Example"
I tried. But we can't add an UILabel into CALayer. I read your code and XFATItemView is using CALayer. So I'm adding a CATextLayer into it instead of UILabel. But sadly, CATextLayer doesn't have word wrap or text trimming option for long text so I need tell server team to give me data with short text. LOL At this time, it's work fine for me.
我试过了。但我们无法在CALayer中添加UILabel。我读了你的代码,XFATItemView正在使用CALayer。所以我在其中添加CATextLayer而不是UILabel。 但遗憾的是,CATextLayer没有长文本的自动换行或文本修剪选项,所以我需要告诉服务器团队给我短文本的数据。哈哈 在这个时候,它对我来说很好。
你说的对,并不支持自定义title