美文网首页
iOS设置tabbar顶部横线阴影效果

iOS设置tabbar顶部横线阴影效果

作者: 研发组的小仙女 | 来源:发表于2018-06-23 15:03 被阅读0次

直接上代码

//设置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;

}

相关文章

网友评论

      本文标题:iOS设置tabbar顶部横线阴影效果

      本文链接:https://www.haomeiwen.com/subject/droryftx.html