0
首先,我有一個用UIView繪製的項目。我想繪製20行,一行有4項,所以有5行。我的問題是我如何找到或計算項目的所有位置。如何在iPhone中計算Fram的Item的位置?
首先,我有一個用UIView繪製的項目。我想繪製20行,一行有4項,所以有5行。我的問題是我如何找到或計算項目的所有位置。如何在iPhone中計算Fram的Item的位置?
假設一個iPhone:
const float itemWidth = 320.0/4;
const float itemHeight = 480.0/4;
for (int row = 0; row < 5; row++)
for (int col = 0; col < 4; col++)
{
CGRect frm = CGRectMake(col * itemWidth, row * itemHeight, itemWidth, itemHeight);
// frm contains the position and size of each element
}
需求調整爲iPad或者如果你想的元素之間的填充。
通過使用初等數學,也許? – 2012-08-13 10:51:27