3
- (Unit*) init
{
if (self = [super init])
{
location = CGPointMake(100.0, 100.0);
self.text = @"Test Text";
self.backgroundColor = [UIColor redColor];
self.font = [UIFont fontWithName:@"Georgia" size:40.0];
self.bounds = CGRectMake(0,
0,
[self.text sizeWithFont:self.font].width,
[self.text sizeWithFont:self.font].height);
}
它適用於大小調整,但如果我更改CGRectMake
中前兩個參數的值,則UILabel
不會移動到該位置。我究竟做錯了什麼?以編程方式將UILabels移動到(X,Y)位置?
另外,有沒有一種方法可以移動UILabel
的(X,Y)一種方式,我不必每次都創建新的CGRectMake
()?
謝謝,它的工作! :) – Derek 2012-03-17 01:00:51
沒問題。如果您將該標籤大量移動到預定位置,您可以考慮使用#define常數來使您的工作更輕鬆一點。 – Adis 2012-03-17 01:06:15