2012-08-13 27 views

回答

2

假設一個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或者如果你想的元素之間的填充。