Şimdi bir süredir bununla uğraşıyor ve biraz yardıma ihtiyacım var. Ekranımın merkezinden (160,200) 14,4 derece ayrımda 25 satır çizmek istiyorum.Core Graphics - bir açı ile bir çizgi çizme
UIImage*backgroundImage = [UIImage imageNamed:@"Primate Background Only.png"];
[backgroundImage drawInRect:CGRectMake(0, 0, 320, 480)];
//
rect = CGRectMake(0.0, 35.0, 320.0, 320.0);
CGContextRef contextRef = UIGraphicsGetCurrentContext(); // Get the contextRef
CGContextSetLineWidth (contextRef, 0.5); // Set the border width
CGContextSetRGBFillColor (contextRef, (219.0f/255.0f), (219.0f/255.0f), (219.0f/255.0f), 0.05f); // Set the circle fill color to GREEN
CGContextSetRGBStrokeColor (contextRef, 0.0, 0.0, 0.0, 0.2); // Set the circle border color to BLACK
CGContextFillEllipseInRect (contextRef, rect); // Fill the circle with the fill color
CGContextStrokeEllipseInRect (contextRef, rect); // Draw the circle border
// Çiz Inner Circle
rect = CGRectMake(25.0, 60.0, 270.0, 270.0); // Get the contextRef
CGContextSetLineWidth (contextRef, 0.5); // Set the border width
CGContextSetRGBFillColor (contextRef, (219.0f/255.0f), (219.0f/255.0f), (219.0f/255.0f), 0.25f);
CGContextSetRGBStrokeColor (contextRef, 0.0, 0.0, 0.0, 0.2); // Set the circle border color to BLACK
CGContextFillEllipseInRect (contextRef, rect); // Fill the circle with the fill color
CGContextStrokeEllipseInRect (contextRef, rect);
Dış Daire Çiz - x 14.4 derecelik çarpanı nerede olduğunu döngü için bu kod satırını kullanıyoruz
// Çizgiler Çizelgesi
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(context, 0.0, 0.0);
for (x=1; x<26; x++) {
CGContextSetLineWidth (context, 0.5);
CGContextSetRGBStrokeColor (context, 0.0, 0.0, 0.0, 0.25);
CGContextMoveToPoint (context, 160, 200);
CGContextAddLineToPoint (context, (160.0 * (cos((x*14.4)*(M_PI/180)))), (160.0 * (sin((x*14.4)*(M_PI/180))))); // The angle is in degrees
CGContextAddLineToPoint (context, 200, 65);
CGContextAddLineToPoint (context, 160, 200);
CGContextStrokePath(context); // Why is this not showing both line color and infill?
CGContextSetFillColorWithColor (context, [UIColor whiteColor].CGColor);
CGContextFillPath (context);
CGContextRef context = UIGraphicsGetCurrentContext();
}
(Burada bir resim göndermeyi planladım ama bana izin vermeyecek!)
Birisi lütfen trig işlevlerimi düzeltebilir mi? Bu saat 12:00 ile 24:00 arasında saat yönünde 25 satır çizmektir. Bunun yerine sadece 90 derece geri çekiliyor, sonra geri dönüyor, tüm hatlar aynı zamanda uzunluktadır.
Çok minnettar
Üstü istendiği gibi yedekte dış çevreleri ve iç kesimleri çizmek için kullanılan kod büyük bir örnektir. Bir sonraki fotoğrafı yüklemeyi deneyeceğim.
CGContextAddLineToPoint(context, (160.0 * (cos((x*14.4)*(M_PI/180)))),
(160.0 * (sin((x*14.4)*(M_PI/180)))));
olması gerektiği:
Trigonometri iyi görünüyor, bize daha fazla kod gösterebilir misiniz? X'yi tekrarlayan döngü, vb. –
Gustav haklı. Ayrıca, görüntüyü başka bir yere yükleyebilir ve ona bir bağlantı sağlayabiliyorsanız, yeterli itibara sahip biri, yayınınızı düzenlemek için yayınınızı düzenleyebilir. – Tommy
Kodunuzu yeniden düzenlerim ama çok fazla ... yeniden biçimlendirebilir misiniz lütfen okunabilir mi? Bunun dışında kasıtlı olarak gizlemeye çalışın :) –