本文介绍了SKLabelHorizo​​ntalAlignmentMode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以给我如何使用SKLabelHorizo​​ntalAlignmentMode的例子吗?

Can someone give me an example of how to use SKLabelHorizontalAlignmentMode?

下面是如何我确定我的标签:

Here's how I'm defining my label:

RunningLevelLabel = [SKLabelNode labelNodeWithFontNamed:@"Chalkduster" ];
RunningLevelLabel.text = [NSString stringWithFormat:@"%i",numberOfBonusAlienPoints];
RunningLevelLabel.fontSize = 36;
RunningLevelLabel.position = CGPointMake(-10,-50);  // offscreen
RunningLevelLabel.fontColor = [SKColor grayColor];

[StartScreenWindow addChild:RunningLevelLabel];

谢谢,富

推荐答案

首先,创建一个标签:

  SKLabelNode *scoreLabel = [SKLabelNode labelNodeWithFontNamed:@"Arial"];
  scoreLabel.text = @"00000";
  scoreLabel.fontSize  = 18;
  scoreLabel.fontColor = [UIColor blackColor];
  scoreLabel.position  = CGPointMake(200, 300);
  [self addChild: scoreLabel];

现在,您可以对齐的标签有:

Now, you can align the label with:

 scoreLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeCenter;

scoreLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeRight;

scoreLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeLeft;

该输出如图所示:

请编码.............:)

Keep coding............. :)

这篇关于SKLabelHorizo​​ntalAlignmentMode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 15:31