我使用AsyncDisplayKit写入按钮,并使用ASButtonNode,但使用- (void)setAttributedTitle:(NSAttributedString *)title forState:(ASButtonState)state时无法设置标题。它可以响应动作,但是没有标题。我担心还是需要设置其他内容?

这是代码:

NSDictionary *placeholderAttrs = @{NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue-LightItalic" size:14.0f] , NSForegroundColorAttributeName: [UIColor greenColor] };

ASButtonNode *button = [[ASButtonNode alloc] init];
[button setAttributedTitle:[[NSAttributedString alloc] initWithString:@"button" attributes:placeholderAttrs] forState:ASButtonStateNormal];
[button addTarget:self action:@selector(action:) forControlEvents:ASControlNodeEventTouchUpInside];
[button setFrame:CGRectMake(20, 20, 100, 44)];
button.backgroundColor = [UIColor redColor];
button.titleNode.displaysAsynchronously = NO;
[self.view addSubnode:button];

谢谢。

最佳答案

@leo,看来您可能只需要测量ASButtonNode才能将其添加到视图中。
[button measure:...];

关于ios - AsyncDisplayKit ASButtonNode setTitle不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34782573/

10-10 12:47