如何在透明的UIView中添加阴影? [英] How to add shadow to a transparent UIView?

查看:225
本文介绍了如何在透明的UIView中添加阴影?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何重现此阴影?我的问题是,如果我使用高alpha色或clearColor,则没有阴影;如果我使用低alpha色,则无法在印版下方看到阴影。随着音量级别(彩色部分)的变化,阴影也在移动,因此它并不是纯粹的Photoshop。

How can I reproduce this shadowing? My problem, that if I use high alpha color or clearColor, there is no drop shadow, if I use low alpha color, I can't see the drop shadow under the plate. As the level of the volume is changing (colorful part) the shadow is moving also, so it is not pure Photoshop.

推荐答案

尝试使用这些特性您的看法。它可能以某些东西结束

try something using thoses properies of your view. it might end up with something

    view.layer.shadowColor = [UIColor colorWithWhite:.5 alpha:1].CGColor;
    view.layer.shadowRadius = 4.0f;
    view.layer.shadowPath = CGPathCreateWithRect(CGRectMake(0, 0, 50, 50), NULL);
    view.layer.shadowOpacity = 1.0f;
    view.layer.shadowOffset = CGSizeMake(1, 1);

如果CGPathRelease(rect)最后不好意思,它就是在泄漏。

it's leaking by the way should CGPathRelease(rect) at the end sorry.

这篇关于如何在透明的UIView中添加阴影?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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