
直接上代碼
//設(shè)置tabbar頂部line陰影 ?
UIImage * image = [self imageWithColor:[UIColor blackColor] size:CGSizeMake(gScreenWidth, 0.7)];
[self.tabBar setShadowImage:image];
?self.tabBar.layer.shadowColor = [UIColor blackColor].CGColor; ? ?
self.tabBar.layer.shadowOffset = CGSizeMake(0, -3); ? ?
self.tabBar.layer.shadowOpacity = 0.25;?
- (UIImage*)imageWithColor:(UIColor*)color size:(CGSize)size {
? ? if(!color || size.width<=0|| size.height<=0)returnnil;
? ?CGRectrect =CGRectMake(0.0f,0.0f, size.width, size.height);
? ? UIGraphicsBeginImageContextWithOptions(rect.size,NO, 0);
? ? CGContextRef context = UIGraphicsGetCurrentContext();
? ? CGContextSetFillColorWithColor(context, color.CGColor);
? ? CGContextFillRect(context, rect);
? ? UIImage *image =UIGraphicsGetImageFromCurrentImageContext();
? ? UIGraphicsEndImageContext();
? ? returnimage;
}