由于此版本暫未自定義tabBar的需求,因此直接寫在TabBarController中盖袭;
親測(cè)仍秤,感覺這樣比設(shè)置陰影圖片效果要好的多Oü睢!诗力!
注:參照網(wǎng)上資料以及自己實(shí)踐當(dāng)作資料或筆記以備后用
?[self.tabBar setShadowImage:[UIImage imageWithColor:HCT_TABBARTOP_LINE size:CGSizeMake(SCREEN_WIDTH, 0.7)]];
? ? self.tabBar.layer.shadowColor = HCT_TABBARTOP_LINE.CGColor;
? ? self.tabBar.layer.shadowOffset = CGSizeMake(0, -5);
? ? self.tabBar.layer.shadowOpacity = 0.5;//陰影透明度凰浮,默認(rèn)0
創(chuàng)建UIImage的分類:
+ (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;
}