gpt4 book ai didi

ios - AsyncDisplayKit ASButtonNode setTitle 不起作用

转载 作者:行者123 更新时间:2023-11-29 12:06:33 25 4
gpt4 key购买 nike

我用AsyncDisplayKit写button,用ASButtonNode,但是用时不能设置标题- (void)setAttributedTitle:(NSAttributedString *)状态的标题:(ASButtonState)state 。它可以响应 Action ,但没有标题。我担心还是需要设置其他东西?

代码如下:

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 添加到 View 之前对其进行测量。

[按钮尺寸:...];

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com