1

我正在使用来滚动 uilabel 文本,并 使用来实现发光效果。但是我想要发光和选取框 uilabel 文本,我已经从上面的代码中用 RSSGlowLabelclass 替换了 UILabel。但我没有得到发光效果。任何人都可以告诉我如何实现这一目标。

4

1 回答 1

4

如果您自己编写代码,可能会容易得多。从这个开始:

float alph = 0.7;

- (void)viewDidLoad {
    [super viewDidLoad];
    glowLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 100)];
    NSString *string = @"some text";
    glowLabel.text = string;
    glowLabel.textColor = [UIColor blueColor];
    [self.view addSubview:glowLabel];
    glowLabel.alpha = alph;
    [NSTimer scheduledTimerWithTimeInterval:0.4
                                   target:self
                                   selector:@selector(glowMarquee)
                                   userInfo:nil
                                   repeats:YES];
}

-(void)glowMarquee {
    alph = (alph == 1) ? 0.7 : 1; // Switch value of alph
    [UIView beginAnimations:@"alpha" context:NULL];
    [UIView setAnimationDuration:0.4];        
    glowLabel.alpha = alph;
    [UIView commitAnimations];
}

现在只需在glowMarquee方法中添加跑马灯逻辑,或者为跑马灯创建一个单独的方法和另一个定时器来控制它,这样两者就可以独立控制了。

于 2012-04-26T06:09:17.273 回答