Creating a shadow view

I have a UIView set as "shadow", and I put this view behind a UIImageView to create a shadow effect. The only problem is, if you decrease the alpha of the image, you can see the white part of the UIView. How do I hide the whole UIView except for the shadow? Setting the backgroundColor to clearColor hides both the view and the shadow, which doesn't help. Thanks.

shadow.alpha = 0.95; shadow.layer.cornerRadius = 10; shadow.layer.shadowColor = [UIColor blackColor].CGColor; shadow.layer.shadowOpacity = 1.0; shadow.layer.shadowRadius = 10.0; shadow.layer.shadowOffset = CGSizeMake(0, 4);

-------------Problems Reply------------

Have you tried modifying the UIImageView's layer to have the shadow, rather than having two views?

If that doesn't give the desired output, does a black UIView work? If you post a screenshot and the desired effect, maybe I can be of more assistance.

I don't think it's possible to do what you're attempting using the built-in shadow facilities. As you've discovered, there has to be something drawn in order for Quartz to have an outline to automatically shadow. (In this case, it's the background roundrect of the view.)

If you specify an explicit roundrect shadowPath for the shadow view's layer, that will do away with the need for the view to actually draw anything. However, the shadow itself appears to be constructed by filling the shadow path and then blurring and translating the resulting image, so you'll end up with essentially the same effect of a black background for the view.

I agree with Ryan Oksenhorn that you'd be better off working with the image view itself. If you add a shadow there, its opacity will drop with the view's, but that's probably all for the better. Do you really want to fade the image and leave a disembodied shadow behind?

How about you set

shadow.backgroundColor = [UIColor blackColor];
shadow.alpha = 1.0;

Category:iphone Views:1 Time:2012-03-04

Related post

  • Create inner shadow in UIView 2012-02-09

    This question already has an answer here: Inner shadow effect on UIView layer? 9 answers I would like create an inner shadow on my UIView on iPad like that : This UIView could change size so I can't use a simple image to create this kind of shadow. I

  • iOS 5 Create a custom view 2012-02-29

    I was wondering what is the best approach in creating a view such as the one on the left hand side of the following ? I know how to make apps that use the templates in the storyboard but kind of lost on the guideline when it comes to creating custom

  • Backup error: Details: Insufficient storage available to create either shadow copy storage file or other shadow copy data 2012-05-20

    This is my third query to the same subject because I felt that I did not give sufficient details on my first two. I am trying to backup my files to an external hard drive (Iomega_hdd (E:) which is brand new and has 398.11 GB free space still but enco

  • VSS error: Error creating the Shadow Copy Provider COM class - 0x80080005, Server execution failed 2014-06-11

    Using win 7 SP1 x64 When loading Windows Update, 'Creating a Restore Point' never finishes. Tried restarting VSS service. It fails to start. Ran chkdsk c: /F /R - no help Thanks for any ideas, Tom --------------Solutions------------- Hi Tom, What hap

  • Sql Server equivalent to Oracle's CREATE OR REPLACE VIEW 2008-10-02

    In Oracle, I can re-create a view with a single statement, as shown here: CREATE OR REPLACE VIEW MY_VIEW AS SELECT SOME_FIELD FROM SOME_TABLE WHERE SOME_CONDITIONS As the syntax implies, this will drop the old view and re-create it with whatever defi

  • Creating a navigation view in Interface Builder 2009-02-13

    I'm trying to create a navigation view in the Interface Builder. It's not in the MainWindow.xib, so the relevant sample project on the Apple Dev. site is useless. The most logical (and cleanest) way to approach this seems to create a Xib-file where t

  • Unable to create a simple view on Oracle table 2009-04-09

    An external DB admin guy exported a production database and imported it into test environment. We are using Oracle 9.2. Majority of imported database objects (tables, views, idexes, packages,...) works fine, but we have problems with three specific t

  • ASP.NET MVC Problem of creating strong-typed view 2009-04-21

    I'm learning ASP.MVC now. I got some problems of creating strong-typed view. I added Entity Data Model to Models, and then I tried to add a strong-typed view based on the Entity Data Model I created. But I cannot see any class in "View data class" in

  • How Do I Use Entity Object Navigation Properties In A DropDownList On My Strongly Typed ASP.NET MVC Create and Edit Views? 2009-05-16

    I've got an Entity Data Model with Product and Family types. Each Product has one Family. I'm using this model with an ASP.NET MVC web site. I want Family DropDownLists on the Create and Edit Views of my Product controller. How Do I Use Entity Object

  • iPhone - creating a loading view 2009-05-21

    When the app is in one view controller, I want to add a view to simulate that data is being loaded when I click my tab bar controller to open another view controller. Example: When I the app is in the recorder-view, I want it to show a loading view (

  • What's the best way to create grouped table view controllers on the iphone? 2009-06-14

    UITableViewController has an initWithStyle method where you pass it the style you want the table view to use, plain or grouped. These means that to create and use my table view controller, somewhere else in the code, possibly in multiple places, I do

  • Can I create a dynamic view of xml data in Sql Server 2005? 2009-07-02

    We have a situation where we need to store form data in our sql server but each new job we setup will have different fields with different field names and lengths. An example Job 1: Field 1: first_name - varchar(20) Field 2: last_name - varchar(30) J

  • CREATE OR REPLACE VIEW sql error 2009-08-05

    Trying to update a table view using: CREATE OR REPLACE VIEW [vtable] AS SELECT * FROM Files_Table ORDER BY File The table is returning the old view, not the updated. Statement tested in the Sqlite database browser: Error message from database engine:

  • Creating a Navigation View inside the standard Flipside view? 2009-08-19

    Does anyone know how to create a Navigation View inside a standard Flipside View to read and update settings? If so, can you post some code on doing this. --------------Solutions------------- You could make the flipside view a subclass of UINavigatio

  • creating a mvc view for an action from a string 2009-09-10

    I want to create a view from scratch for a controller action ... what i want to put in the view i have saved it in the database as a table .... can i do that??? if yes anybody can help ... This article i already went through this article i wanted to

  • how to create Gantt Chart view on Iphone sreen 2009-09-15

    I wonder how to create Gantt Chart view or (Matrix table on PC )on Iphone sreen. see demo here you know the Iphone's screen is very small(320x480), the Gantt Chart view is large. what API or Framework do

  • Creating a tab view programatically with Cocoa/Objective C 2009-10-13

    I need to create a tab view programatically using objective C and cocoa but I can't find any good resources showing how to do this. Can anyone suggest something? --------------Solutions------------- This adds a tab view to a window: NSTabView *tabVie

  • Creating a [materialised]view from generic data in Oracle/Mysql 2010-06-18

    I have a generic datamodel with 3 tables CREATE TABLE Properties ( propertyId int(11) NOT NULL AUTO_INCREMENT, name varchar(80) NOT NULL ) CREATE TABLE Customers ( customerId int(11) NOT NULL AUTO_INCREMENT, customerName varchar(80) NOT NULL ) CREATE

  • Visual Studio 2010 ASP.NET MVC: Create Strongly Typed View Not Showing My Classes 2010-07-12

    For some reason, when I create a new view and select 'Create Strongly Typed View', when I try to select a view data class from my project I find that its not in the list? Classes from all my project's references (external references) are there, but N

Copyright (C), All Rights Reserved.

processed in 0.084 (s). 11 q(s)