import "ViewController.h"
#define IOS_SystemVersion [[[UIDevice currentDevice]systemVersion]floatValue]
#define WIDThH [[UIScreen mainScreen] bounds].size.width
#define HEIGHT [[UIScreen mainScreen] bounds].size.height
#define kBulldesFont [UIFont systemFontOfSize:15]
@interface ViewController ()
{
UILabel *_contentLabel;
NSTimer *_timer;
int _number;
CGSize _size;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor = [UIColor whiteColor];
UIView *view = [[UIView alloc] init];
view.frame = CGRectMake(0, 60, WIDThH, 45);
view.backgroundColor = [UIColor redColor];
[self.view addSubview:view];
_number = 0;
_contentLabel = [[UILabel alloc] init];
_contentLabel.text = @"今天是個(gè)好日子,神就是光、道路、真理和生命,敬畏耶和華這人便是有福?;揭d是世人唯一的救世主!";
_size = [_contentLabel.text sizeWithAttributes:@{NSFontAttributeName:kBulldesFont}];
_contentLabel.frame = CGRectMake(WIDThH, 0, _size.width, 45);
_contentLabel.font = kBulldesFont;
_contentLabel.textColor = [UIColor whiteColor];
[self.view addSubview:_contentLabel];
_timer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(timeFireMethod) userInfo:nil repeats:YES];
}
#pragma mark 計(jì)時(shí)器
-(void)timeFireMethod
{
if (_number*0.5<_size.width + WIDThH) {
_number++;
_contentLabel.frame = CGRectMake(WIDThH - _number*0.5, 60, _size.width, 45);
}else{
_number = 0;
_contentLabel.frame = CGRectMake(WIDThH - _number*0.5, 60, _size.width, 45);
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。