2015-04-03 26 views
0

我做了一個自定義的UIView在它上面做一些動畫。 我需要計算它的幀大小,因爲它在iPhone 6不同,6個加和iPhone 5的獲取UITabelViewCell中的視圖高度動態變化

我使用

self.frame, self.layer.presentationlayer.frame 

但他們都給出錯誤的框架,我需要的視圖的框架它出現在單元格之後。 中的cellForRowAtIndexPath我調用這個函數

[cell.answer1 showStatistics:percent]; 

的方法首先我做

CGRect Frame= self.frame; 
dempedLayer=[[UIView alloc] initWithFrame:Frame]; 
[dempedLayer setBackgroundColor:[UIColor blackColor]]; 
[dempedLayer setAlpha:0.35]; 
[self addSubview:dempedLayer]; 

然後我讓使用CAShapeLayer和CABasicAnimation

CABasicAnimation *rotationAnimation=[CABasicAnimation animationWithKeyPath:@"strokeEnd"] 
+0

你可以發佈一段代碼,你可以調用這些方法,所以我們可以看到你的視圖如何看起來像 – SteBra 2015-04-03 13:39:54

+0

@SteBra我把代碼 – khaled 2015-04-03 13:46:29

+0

做一個UITableViewCell的類方法(如果單元格是自定義的),然後在你的視圖控制器的heightForRowAtIndexPath,調用該方法根據其數據獲取單元格高度。 – msmq 2015-04-03 14:14:35

回答

-1

,如果你正在嘗試做動畫的一些動畫這裏是如何實現它: -

[UIView animateWithDuration:0.5 animations^{ 

CGRect viewFrame = self.yourView.frame; 

viewFrame.size.height += 100; 

self.yourView.frame = viewFrame; 

}]; 

如果這不是你正在尋找的,可能你應該檢查你在IB/Storyboard中設置的自動調整參數。

+0

實際上我使用CABasicAnimation * rotationAnimation = [CABasicAnimation animationWithKeyPath:@「strokeEnd」] – khaled 2015-04-03 13:44:50