Barackula from mark mannschreck on Vimeo.
for(NSString* family in [UIFont familyNames]){ Debug(@"%@ %@",family, [UIFont fontNamesForFamilyName:family]); }
#import "MATCAlertView.h" @implementation MATCAlertView #pragma mark - #pragma mark Initialization and teardown - (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { // Initialization code } return self; } - (void)dealloc { [super dealloc]; } #pragma mark - #pragma mark Drawing methods + (CGColorSpaceRef)genericRGBSpace; { static CGColorSpaceRef space = NULL; if (space == NULL) { space = CGColorSpaceCreateDeviceRGB(); } return space; } + (CGColorRef)whiteColor; { static CGColorRef white = NULL; if (white == NULL) { CGFloat values[4] = {1.0, 1.0, 1.0, 1.0}; white = CGColorCreate([self genericRGBSpace], values); } return white; } + (CGColorRef)shadowColor; { static CGColorRef shadowColor = NULL; if (shadowColor == NULL) { CGFloat values[4] = {0.0, 0.0, 0.0, 0.5}; shadowColor = CGColorCreate([self genericRGBSpace], values); } return shadowColor; } + (CGColorRef)translucentBlueColor; { static CGColorRef translucentBlue = NULL; if (translucentBlue == NULL) { CGFloat values[4] = {0.13, 0.24, 0.44, 0.7}; translucentBlue = CGColorCreate([self genericRGBSpace], values); } return translucentBlue; } - (void)drawRect:(CGRect)rect { CGFloat shadowRadius = 4.0f; CGContextRef context = UIGraphicsGetCurrentContext(); CGRect currentBounds = self.bounds; CGContextSaveGState(context); // Set up the shadow around the view, which requires a slight inset on the view CGContextSetShadowWithColor( context, CGSizeMake(0.0f, -shadowRadius), shadowRadius, [MATCAlertView shadowColor] ); // Draw the blue background rectangle and border CGContextSetLineWidth(context, 2.0f); CGContextSetStrokeColorWithColor(context, [MATCAlertView whiteColor]); CGContextSetFillColorWithColor(context, [MATCAlertView translucentBlueColor]); CGFloat cornerRadius = 5.0f; CGRect actualViewRect = CGRectMake(shadowRadius + 0.5, 1.5f, currentBounds.size.width - shadowRadius * 2.0f, currentBounds.size.height - shadowRadius*2.5f); CGContextBeginPath(context); CGContextMoveToPoint(context, CGRectGetMinX(actualViewRect) + cornerRadius + 0.5, CGRectGetMinY(actualViewRect) + 0.5); CGContextAddArc(context, CGRectGetMaxX(actualViewRect) - cornerRadius + 0.5, CGRectGetMinY(actualViewRect) + cornerRadius + 0.5, cornerRadius, 3 * M_PI / 2, 0, 0); CGContextAddArc(context, CGRectGetMaxX(actualViewRect) - cornerRadius + 0.5, CGRectGetMaxY(actualViewRect) - cornerRadius + 0.5, cornerRadius, 0, M_PI / 2, 0); CGContextAddArc(context, CGRectGetMinX(actualViewRect) + cornerRadius + 0.5, CGRectGetMaxY(actualViewRect) - cornerRadius + 0.5, cornerRadius, M_PI / 2, M_PI, 0); CGContextAddArc(context, CGRectGetMinX(actualViewRect) + cornerRadius + 0.5, CGRectGetMinY(actualViewRect) + cornerRadius + 0.5, cornerRadius, M_PI, 3 * M_PI / 2, 0); CGContextClosePath(context); CGContextDrawPath(context, kCGPathFillStroke); CGContextRestoreGState(context); // // // Clip the gloss clipping path to the rounded rectangle // CGContextBeginPath(context); // CGContextMoveToPoint(context, CGRectGetMinX(actualViewRect) + cornerRadius + 0.5, CGRectGetMinY(actualViewRect) + 0.5); // CGContextAddArc(context, CGRectGetMaxX(actualViewRect) - cornerRadius + 0.5, CGRectGetMinY(actualViewRect) + cornerRadius + 0.5, cornerRadius, 3 * M_PI / 2, 0, 0); // CGContextAddArc(context, CGRectGetMaxX(actualViewRect) - cornerRadius + 0.5, CGRectGetMaxY(actualViewRect) - cornerRadius + 0.5, cornerRadius, 0, M_PI / 2, 0); // CGContextAddArc(context, CGRectGetMinX(actualViewRect) + cornerRadius + 0.5, CGRectGetMaxY(actualViewRect) - cornerRadius + 0.5, cornerRadius, M_PI / 2, M_PI, 0); // CGContextAddArc(context, CGRectGetMinX(actualViewRect) + cornerRadius + 0.5, CGRectGetMinY(actualViewRect) + cornerRadius + 0.5, cornerRadius, M_PI, 3 * M_PI / 2, 0); // CGContextClosePath(context); // CGContextClip(context); // // // Set up a clipping path for the gloss gradient // CGFloat glossRadius = 600.0f; // CGPoint glossCenterPoint = CGPointMake(CGRectGetMidX(currentBounds), 30.0 - glossRadius); // CGContextBeginPath(context); // CGContextMoveToPoint(context, glossCenterPoint.x, glossCenterPoint.y); // CGContextAddArc(context, glossCenterPoint.x, glossCenterPoint.y, glossRadius, 0.0, M_PI, 0 // ); // CGContextClosePath(context); // CGContextClip(context); // // // Draw the gloss gradient CGGradientRef glossGradient; CGFloat locations[2] = { 0.0, 1.0 }; CGFloat components[8] = { 1.0, 1.0, 1.0, 0.65, // Start color 1.0, 1.0, 1.0, 0.06 }; // End color glossGradient = CGGradientCreateWithColorComponents([MATCAlertView genericRGBSpace], components, locations, 2); CGPoint topCenter = CGPointMake(CGRectGetMidX(currentBounds), 0.0f); CGPoint midCenter = CGPointMake(CGRectGetMidX(currentBounds), 30.0f); CGContextDrawLinearGradient(context, glossGradient, topCenter, midCenter, 0); CGGradientRelease(glossGradient); } @end
Last modified
13 years ago
Last modified on 11/14/11 17:14:46
Note:
See TracWiki
for help on using the wiki.