Evg*_*nik 3 objective-c marquee nstextfield uitextfield uilabel
我需要UILabel在Xcode中制作选框.选框将从右向左滚动.
我和其他人CCScrollingLabel也试过了 JHTickerView.但我找不到简单的代码与marquee没有任何视图/数组/一些愚蠢的库和其他人
如何制作选框UILabel?(UITextField和NSTextField都OK太).
你需要NSTimer并且你需要调用一个方法:
*这适用于OSX,您可以轻松将其转换为iOS,NSTextField并且UILabel具有不同的方法.
-(void)awakeFromNib{
self.myTimer=[NSTimer new];
self.fullString=@"This is a long string to be shown.";
[self.label setAlignment:NSRightTextAlignment];
}
-(void)scrollText:(id)parameter{
static NSInteger len;
[self.label setStringValue:[self.fullString substringWithRange:NSMakeRange(0, len++)]];
if (self.label.stringValue.length==self.fullString.length) {
[self.myTimer invalidate];
}
}
- (IBAction)buttonAction:(id)sender {
self.myTimer = [NSTimer scheduledTimerWithTimeInterval:0.2f
target: self
selector:@selector(scrollText:)
userInfo: nil
repeats:YES];
}
Run Code Online (Sandbox Code Playgroud)