Annotation bubbles on iOS Map
First:
First, you can customize a View for drawing. You can draw all the images you want. <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4NCjxwPsnPtPrC66O6PC9wPg0KPHByZSBjbGFzcz0 = "brush: java;"> This method gets the context. -(Void) drawRect :( CGRect) rect {[self drawInContext: UIGraphicsGetCurrentContext ()]; self. layer. shadowColor = [[UIColor clearColor] CGColor]; self. layer. shadowOpacity = 1.0; self. layer. shadowOffset = CGSizeMake (0.0f, 0.0f );}'''
-(Void) drawInContext :( CGContextRef) context {
// Set the width of the current image
CGContextSetLineWidth (context, 2.0 );
// Fill in the bubble color and set the transparency
// CGContextSetFillColorWithColor (context, [UIColor colorWithRed: 0.3 green: 0.3 blue: 0.3 alpha: 0.8]. CGColor );
// Fill color
CGContextSetFillColorWithColor (context, [UIColor redColor]. CGColor );
// [Self getDrawPath: context]; // fill the color CGContextFillPath (context) in the shape );
}
-(Void) getDrawPath :( CGContextRef) context {
// Retrieve the current image size
CGRect rrect = self. bounds;
NSLog (@ "% f", self. frame. size. width );
NSLog (@ "% f", self. frame. size. height );
// Set the garden radian CGFloat radius = 30.0; CGFloat minx = CGRectGetMinX (rrect), // 0 // midpoint midx = CGRectGetMidX (rrect ), // 100 // Xmaxx = CGRectGetMaxX (rrect); // 200 CGFloat miny = CGRectGetMinY (rrect ), // 0 // maximum height Ymaxy = CGRectGetMaxY (rrect)-kArrorHeight; // 60 // 1. draw a downward triangle // 2. set the right point of the Start triangle to CGContextMoveToPoint (context, midx + kArrorHeight, maxy); // 3. link to the right-> link to the bottom-level vertex CGContextAddLineToPoint (context, midx, maxy + kArrorHeight ); // Draw a straight line // 4. link the bottom point to the leftmost point. CGContextAddLineToPoint (context, midx-kArrorHeight, maxy); // draw 4 arcs // CGContextAddArcToPoint (context, x1, y1, x2, y2, CGfloat radius ); // after painting, the current point is not in minx or miny, but at the end of the arc CGContextAddArcToPoint (context, minx, maxy, minx, miny, radius ); // after painting, the current point is not in minx or miny, but at the end of the arc CGContextAddArcToPoint (context, minx, miny, maxx, miny, radius); CGContextAddArcToPoint (context, maxx, miny, maxx, maxy, radius); CGContextAddArcToPoint (context, maxx, maxy, midx, maxy, radius); CGContextClosePath (context );
}
''