2
我已經完成了下面的教程來創建一個UIKit旋轉輪控制。 http://www.raywenderlich.com/9864/how-to-create-a-rotating-wheel-control-with-uikit旋轉CALayers
部分中「擺出輪」的教程,車輪被繪製順時針開始圓的左側部位(見的紅色標籤的截圖)。所以它從左邊的網站開始。
但是,我想從0的圓圈的正確位置開始 - 現在屏幕截圖上的位置是4。不幸的是,我不知道如何才能做到這一點。當然,數字或圖片的旋轉應該與現在完全相反。所以現在4旋轉180度,這應該是正常的。
有人可以幫我嗎?會很好。
問候
當前drawWheel功能:
// 3 - Create the sectors
for (int i = 0; i < _numberOfSections; i++) {
// 4 - Create image view
UIImageView *im = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"segment.png"]];
im.layer.anchorPoint = CGPointMake(1.0f, 0.5f);
im.layer.position = CGPointMake(_container.bounds.size.width/2.0-_container.frame.origin.x,
_container.bounds.size.height/2.0-_container.frame.origin.y);
im.transform = CGAffineTransformMakeRotation((angleSize * i) + M_PI);
im.alpha = minAlphavalue;
im.tag = i;
if (i == 0) {
im.alpha = maxAlphavalue;
}
// 5 - Set sector image
UIImageView *sectorImage = [[UIImageView alloc] initWithFrame:CGRectMake(12, 100, 40, 40)];
sectorImage.image = [UIImage imageNamed:[NSString stringWithFormat:@"icon%i.png", i]];
[im addSubview:sectorImage];
// 6 - Add image view to container
[_container addSubview:im];
}
Hello trojanfoe!感謝您的回答,現在就按照我的意願開始。只有圖像沒有正確旋轉,hmm不是用CGAffineTransformMakeRotation完成的嗎? – ihkawiss 2013-02-20 13:45:03
是的,我的建議是將'M_PI'加入到'CGAffineTransformMakeRotation()'的調用中。你能否確認你有我發佈的確切代碼(減去'===='中的評論)? – trojanfoe 2013-02-20 13:48:19
我的代碼有點不同,因爲我使用圖像而不是標籤。 我的drawWheel函數現在看起來像本教程的「添加圖形」部分。 (在頁面底部) – ihkawiss 2013-02-20 14:00:37