以前在我的應用程序中,我使用的是這樣的sizeWithFont
。在iOS 7中使用sizeWithAtrributes時,方法調用錯誤的參數太多iPhone
我試圖根據文本標籤的寬度和位置調整圖像的大小和位置。所以我嘗試我喜歡這個,
CGRect rect = CGRectMake(_frame.origin.x + [self.categoryLabel.text sizeWithFont:self.categoryLabel.font].width + 10, y, _imageSize.width, _imageSize.height);
但在iOS的7它已被棄用,並要求sizeWithAttributes。
當我嘗試像這樣我得到這樣的「x」座標。
但是當我用這樣的代碼CGRect rect = CGRectMake(_frame.origin.x + [self.categoryLabel.text sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:self.categoryLabel.frame.size.width+10]}],y,_imageSize.width,_imageSize.height);
即時得到這樣的 「X」 cordinate。
任何人都可以請幫我在這。
謝謝。我試過這種方式CGRect rect = CGRectMake(_frame.origin.x + [self.categoryLabel.text sizeWithAttributes:@ {NSFontAttributeName:[UIFont systemFontOfSize:[self.categoryLabel.frame.size.width] + 10,y,_imageSize。寬度,_imageSize.height]}];現在它顯示「Expected identifier」錯誤 – suji
你可以看看我編輯的答案 – suji
@suji我編輯我的帖子,這是我的代碼中的錯誤。假設你想獲得sizeWithFont:方法的寬度,但說實話我不知道你想達到什麼目的。你的問題是如何解決一個錯誤,編輯後的代碼應該這樣做。 – Greg