A dynamic calendar Tab bar icon that changes to the actual date
Is there a way to make one as i have seen one on the istudiez pro app and was wondering how you would do it. This is what I have so far but the text test is not displayed. Not sure why?
@implementation TabBarIcon
CGContextRef CGBitmapContextCreate (
void *data,
size_t width,
size_t height,
size_t bitsPerComponent,
size_t bytesPerRow,
CGColorSpaceRef colorspace,
CGBitmapInfo bitmapInfo
);
-(void)drawRect:(CGRect)Rect{
CGImageRef context = UIGraphicsGetCurrentContext();
CGContextSetTextDrawingMode(context, kCGTextStroke);
CGContextSetRGBFillColor(context, 1.0, 0.0, 0.0, 1.0);
CGContextSelectFont(context, "Arial", 12.0, kCGEncodingMacRoman);
CGAffineTransform transform = CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, 0.0);
CGContextSetTextMatrix(context, transform);
CGContextShowTextAtPoint(context, 100.0开发者_如何学运维, 100.0, "test", strlen("test"));
}
CGImageRef CGBitmapContextCreateImage(CGContextRef context);
@end
Thanks
I'm not familiar with istudiez pro, but it sounds like it's just a matter of assigning a different tab bar image depending on the date; you haven't mentioned whether you're targeting iOS or OSX, but for the former you create an instance of UITabBarItem created with the appropriate image and assign it to the appropriate UIViewController's tabBarItem
.
If it's just "day of the month" you could include all 31 possible images, otherwise you can use Core Graphics to draw the appropriate image at runtime.
精彩评论