Annotation bubbles on iOS Map

Source: Internet
Author: User

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 );

}
''

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.