views:

1342

answers:

2

Hi Everyone:

I am wondering how I can create an outer glow effect outside a UIView on the iPhone, kind of like when clicking a regular NSTextField on the Mac.

Thanks for any help!

+1  A: 

You could create a background image, position it behind the TextField, and have it be slightly larger so the glow part of the image shows around the borders of the text field.

Andrew Johnson
+3  A: 

You can add a custom subview to your UIView that extends beyond the bounds of your UIView. For example:

UITextView* mainView = [[UITextView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)];
mainView.clipsToBounds = NO;

// Add 5 px of padding to the mainView bounds
CGRect borderFrame = CGRectInset(mainView.bounds, -5, -5);
MyBorderView* borderView = [[MyBorderView alloc] initWithFrame:borderFrame];
customView.userInteractionEnabled = NO;
[mainView addSubview:customView];

MyBorderView can draw a border in its -drawRect: method, or you could use UIImageView.

Darren