Description: a custom map popup window.
#import <MapCharting/MapCharting.h> @interface CustomMapBubblePopoverView : MapBubblePopoverView @end
#import "CustomMapBubblePopoverView.h" @implementation CustomMapBubblePopoverView // Initializes popup window - (id)init { self = [super init]; if (self) { self.backgroundColor = [UIColor clearColor]; self.contentMode = UIViewContentModeRedraw; } return self; } - (void)drawRect:(CGRect)rect { // Get current graphic context CGContextRef context = UIGraphicsGetCurrentContext(); // Draw popup window [self drawInContext:context boundsRect:[self bounds]]; } // Draws popup window - (void) drawInContext: (CGContextRef) context boundsRect: (CGRect) boundsRect { MapPlaced *placed = [self placed]; // Create a popup window CGPathRef path = createBubble( CGRectMake(0.5,0.5, boundsRect.size.width-1, boundsRect.size.height-1), [placed borderRadius], 0.5, 14, 11, [self arrowOrientation]); CGContextSetAlpha(context, 1.0); // Set fill [[placed background] applyToContext:context path:path rect:boundsRect]; CGContextSetAlpha(context, 1.0); CGContextSetStrokeColorWithColor(context, [[self borderColor] CGColor]); CGContextAddPath(context, path); // Sets popup window border width CGContextSetLineWidth(context, [placed borderThickness]); CGContextStrokePath(context); // Determine label position in this window CGPoint centerPoint = boundsRect.origin; centerPoint.x += boundsRect.size.width / 2 - 10; centerPoint.y += boundsRect.size.height / 4; // Set label text [[self tintColor] set]; // Render label [[placed ID] drawAtPoint:centerPoint withFont:[UIFont fontWithName:@"Arial" size:14]]; CGPathRelease(path); } @end
See also: