2012-08-09 38 views
0

我是新進入ios編程,所以這可能是一種常見的濫用技術。屬性frameOrigin類型UILabel對象上找不到

在我的視圖控制器我使用下面的代碼:

[timeLabel setTextColor:textColor]; 
[timeLabel setText:[NSDateFormatter localizedStringFromDate:_reservation.date dateStyle:NSDateFormatterNoStyle timeStyle:NSDateFormatterShortStyle]]; 
[timeLabel sizeToFit]; 
[timeLabel setFrameOrigin:CGPointMake(61, 23)]; 

其中timeLabel在頭文件中聲明爲

UILabel *timeLabel; 

與其他常量沿(文字顏色等)

我得到出現以下錯誤:

Property frameOrigin not found on object of type UILabel 

我錯過了什麼?我是否需要在每個標籤上追加另一個框架(我將在表格單元格內的UIButton視圖中使用標籤和象形圖)。

感謝您提前幫忙!

+0

frameOrigin是一個NSView不是UIView的的屬性。而NSView是爲mac而不是ios。 – Ankit 2012-08-09 11:20:47

回答

2

你可以這樣做:

[timeLabel setFrame:CGRectMake(61,23,timeLabel.frame.size.width,timeLabel.frame.size.height)]; 

或者

CGRect frame=timeLabel.frame; 
frame.origin=CGPointMake(61,23); 
timeLabel.frame=frame; 
+0

謝謝你,它的工作。 – smihael 2012-08-09 13:55:18

相關問題