0

为什么给任何图层添加阴影太重?

我试图给我的 UIView 添加一个阴影,它只在这个屏幕上很重。

为什么这么重?我找到的唯一解决方案是在 PNG 中添加阴影图像进行模拟,比使用 QuartzCore 创建阴影更轻。

有什么解决方案更轻吗?

4

1 回答 1

2

使用以下函数为任何控件(如按钮、标签、文本字段或视图)提供阴影,只需将该控件传递给此函数

    - (void)setShadowOnView:(UIView)aView
    {
        CALayer *layer = aView.layer;
        layer.masksToBounds = NO;
        layer.shadowColor = [[UIColor blackColor] CGColor];//change is to set color of shadow
        layer.shadowOpacity = 1.f;//change is to set alpha of shadow
        layer.shadowOffset = CGSizeMake(-2.5f, 0.f);//change is to set size of shadow
        layer.shadowRadius = 5.f;//change is to set radios of shadow
        layer.shadowPath = [[UIBezierPath bezierPathWithRect:aView.bounds] CGPath];
    }

尝试根据您的喜好和要求设置属性..

享受编码......

于 2013-04-25T15:14:32.990 回答