XFAssistiveTouch icon indicating copy to clipboard operation
XFAssistiveTouch copied to clipboard

Add title for items?

Open sonhd92 opened this issue 7 years ago • 3 comments

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..

sonhd92 avatar Oct 18 '17 13:10 sonhd92

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"

xiaofei86 avatar Nov 04 '17 06:11 xiaofei86

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.

sonhd92 avatar Nov 11 '17 03:11 sonhd92

我试过了。但我们无法在CALayer中添加UILabel。我读了你的代码,XFATItemView正在使用CALayer。所以我在其中添加CATextLayer而不是UILabel。 但遗憾的是,CATextLayer没有长文本的自动换行或文本修剪选项,所以我需要告诉服务器团队给我短文本的数据。哈哈 在这个时候,它对我来说很好。

你说的对,并不支持自定义title

q351941406 avatar Oct 04 '18 09:10 q351941406