|
+ (UIImage *)imageForNavigationBar |
|
{ |
|
/* |
|
* 1x44、最下部のドットが灰色でその他は白色の画像を生成する。 |
|
*/ |
|
|
|
CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 44.0f); |
|
UIGraphicsBeginImageContext(rect.size); |
|
CGContextRef context = UIGraphicsGetCurrentContext(); |
|
|
|
// 白で塗りつぶす。 |
|
CGContextSetFillColorWithColor(context, [[UIColor whiteColor] CGColor]); |
|
CGContextFillRect(context, rect); |
|
|
|
// 最下部に灰色の線を引く。 |
|
CGContextSetRGBStrokeColor(context, 0.0, 0.0, 0.0, 0.2); |
|
CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 0.2); |
|
CGContextSetLineJoin(context, kCGLineJoinRound); |
|
CGContextSetLineWidth(context, 1); |
|
CGMutablePathRef pathRef = CGPathCreateMutable(); |
|
CGPathMoveToPoint(pathRef, NULL, 0, 44); |
|
CGPathAddLineToPoint(pathRef, NULL, 1, 44); |
|
CGPathCloseSubpath(pathRef); |
|
CGContextAddPath(context, pathRef); |
|
CGContextFillPath(context); |
|
CGContextAddPath(context, pathRef); |
|
CGContextStrokePath(context); |
|
CGPathRelease(pathRef); |
|
|
|
// コンテキストからUIImageを生成。 |
|
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); |
|
UIGraphicsEndImageContext(); |
|
|
|
return image; |
|
} |