如何在iOS中给像卡一样的影子 [英] How to give shadow like card in iOS

查看:148
本文介绍了如何在iOS中给像卡一样的影子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提供类似于我的iOS应用中的图像卡片的阴影效果

I would like to give shadow effect like card similar to the image in my iOS app

我在UITableViewCell上需要这个图像对我来说也不适用于带有阴影效果的单元格之间的间隙

I need this on UITableViewCell the image will not work for me also the the gaps between cells with shadow effect

推荐答案

在表格视图单元格中使用容器视图并指定标签99.
保持单元格高度比卡片(容器视图)大一点。

Use a container view inside your table view cell and assign tag say 99. Keep the cell height a bit larger then your card (container view).

并给卡片视图留下阴影

UIView* shadowView = [cell viewWithTag:99];
shadowView.backgroundColor=[UIColor colorWithRed:228.0/255.0 green:228.0/255.0 blue:228.0/255.0 alpha:0.5];
[shadowView.layer setCornerRadius:5.0f];
[shadowView.layer setBorderColor:[UIColor lightGrayColor].CGColor];
[shadowView.layer setBorderWidth:0.2f];
[shadowView.layer setShadowColor:[UIColor colorWithRed:225.0/255.0 green:228.0/255.0 blue:228.0/255.0 alpha:1.0].CGColor];
[shadowView.layer setShadowOpacity:1.0];
[shadowView.layer setShadowRadius:5.0];
[shadowView.layer setShadowOffset:CGSizeMake(5.0f, 5.0f)];

这篇关于如何在iOS中给像卡一样的影子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆