这是代码:
[self setTickerLabel: [ [UILabel alloc] initWithFrame:CGRectMake(0,self.vIEw.bounds.size.height - 40,self.vIEw.bounds.size.wIDth,40)]];[self.tickerLabel setFont:[UIFont FontWithname:@"CourIEr" size:TICKER_Font_SIZE]];self.text =[Nsstring stringWithFormat:@"%@",self.result];self.tickerLabel.textAlignment = NSTextAlignmentRight;[self.tickerLabel setText:self.text];[self.tickerLabel setlineBreakMode:NSlineBreakByWorDWrapPing];[NSTimer scheduledTimerWithTimeInterval:TICKER_RATE target:self selector: @selector(nudgeTicker:) userInfo:nil repeats:YES];[self.vIEw addSubvIEw:self.tickerLabel];
轻推Ticker方法执行以下 *** 作:
Nsstring* firstLetter = [self.text substringWithRange: NSMakeRange(0,1)];Nsstring* remainder = [self.text substringWithRange:NSMakeRange(1,[self.text length]-1)];self.text=[remainder stringByAppendingString: firstLetter];self.tickerLabel.text=self.text;
我真的需要一些帮助.我怎样才能解决这个问题?顺便说一句,UILabel的文字是阿拉伯语.
解决方法 有点破解,但一种解决方案是在标签中使用属性字符串,并在字符串末尾包含透明句点(“.”).只需替换你的nudgeTicker:方法.
- (voID)nudgeTicker:(ID)target { Nsstring* firstLetter = [self.text substringWithRange: NSMakeRange(0,1)]; Nsstring* remainder = [self.text substringWithRange:NSMakeRange(1,[self.text length]-1)]; self.text=[remainder stringByAppendingString: firstLetter]; NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:[Nsstring stringWithFormat:@"%@.",self.text]]; [string addAttribute:NSForegroundcolorAttributename value:[UIcolor blackcolor] range:NSMakeRange(0,string.length-1)]; [string addAttribute:NSForegroundcolorAttributename value:[UIcolor clearcolor] range:NSMakeRange(string.length-1,1)]; self.tickerLabel.attributedText = string;}总结
以上是内存溢出为你收集整理的ios – 如何阻止UILabel在最后修剪空间?全部内容,希望文章能够帮你解决ios – 如何阻止UILabel在最后修剪空间?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)