所以我不知道任何方法来绘制文本或字符串,但 UILabel。所以我初始化了标签,但它总是让我的应用程序崩溃。
以下是初始化标签并导致崩溃的方法:
-(无效)setupScore{
scoreLabel = [NSString stringWithFormat:@"%d", score]; scoreLabel.frame = CGRectMake(262, 250, 100, 40); [scoreLabel setText: scoreString]; //normally you'll want a transparent background for your label scoreLabel.backgroundColor = [UIColor clearColor]; //you can use non-standard fonts [scoreLabel setFont:[UIFont fontWithName:@"TimesNewRoman" size: 1.0f]]; //change the label's text color scoreLabel.textColor = [UIColor whiteColor]; //add it to your view scoreLabel.transform = CGAffineTransformMakeRotation(89.53); [self addSubview:scoreLabel]; }
-(无效)setupPausedLabel{
pausedLabel = [NSString stringWithFormat:@"Tap To Resume"]; pausedLabel.frame = CGRectMake(262, 250, 100, 40); [pausedLabel setText: @"Tap To Resume"]; //normally you'll want a transparent background for your label pausedLabel.backgroundColor = [UIColor clearColor]; //you can use non-standard fonts [pausedLabel setFont:[UIFont fontWithName:@"TimesNewRoman" size: 1.0f]]; //change the label's text color pausedLabel.textColor = [UIColor whiteColor]; //add it to your view pausedLabel.transform = CGAffineTransformMakeRotation(89.53); [pausedLabel setHidden: YES]; [self addSubview:pausedLabel]; }
谢谢你的帮助!