Ios 如何以编程方式将标签与x,y坐标对齐
下面是标签的一些其他属性。很明显,nstextalignmentleft不是我想要的。无法理解在何处输入坐标Ios 如何以编程方式将标签与x,y坐标对齐,ios,alignment,label,coordinates,Ios,Alignment,Label,Coordinates,下面是标签的一些其他属性。很明显,nstextalignmentleft不是我想要的。无法理解在何处输入坐标 self.lblTimer = [[UILabel alloc] init]; self.lblTimer.translatesAutoresizingMaskIntoConstraints = NO; self.lblTimer.textAlignment = NSTextAlignmentLeft; self.lblTimer.font = [UIFont systemFontOfS
self.lblTimer = [[UILabel alloc] init];
self.lblTimer.translatesAutoresizingMaskIntoConstraints = NO;
self.lblTimer.textAlignment = NSTextAlignmentLeft;
self.lblTimer.font = [UIFont systemFontOfSize:10];
self.lblTimer.textColor = [UIColor redColor];`self.lblTimer = [[UILabel alloc] init];
由于您已将
self.lblTimer.translatesAutoresizingMaskIntoConstraints
设置为NO
,我猜您希望使用,如果是,我强烈建议您查看
另一种方法是在标签上设置
frame
属性,需要一个CGRect
,在这里您可以给它x和y坐标以及宽度和高度。我认为您误解了文本对齐
的作用。这只是控制标签内的对齐,而不是屏幕上的对齐。如果要在屏幕上定位标签,必须更改其框架
属性:
self.lblTimer.frame = CGRectMake(x,y,width,height);
你想做什么<代码>文本对齐只能设置为左、右、中、对正和自然对齐。您是否希望在标签边缘和文本之间创建偏移?标签是一个计时器,可以向上计数。我只是想把它放在屏幕的左下角。