0

Twitter Bootstrap 有一个表单控件,当处于活动模式时,它会在边框上“发光”,我想知道是否可以在 iPhone 上使用 UITextField 实现这种效果。有人试过吗?

(http://twitter.github.com/bootstrap/base-css.html 搜索表单控件)

4

1 回答 1

4

实现这一点的最简单方法可能是修改其支持层:

CALayer *theLayer = [theTextField layer];
[theLayer setBorderWidth:2.];
[theLayer setBorderColor:[[UIColor blueColor] CGColor]];
[theLayer setShadowColor:[[UIColor blueColor] CGColor]];
[theLayer setShadowOpacity:1.];
[theLayer setShadowRadius:5.];
[theLayer setShadowOffset:CGSizeZero];
[theTextField setClipsToBounds:NO];

IMO 这种方法的最大缺点是 CALayer 阴影操作非常缓慢,因此如果您正在制作动画(例如在滚动/表格视图中),这将基本上无法使用。但是,您可以通过各种增强来获得更高性能的阴影

(另外,你显然不会想要我使用的丑陋的深蓝色!)

于 2012-04-04T20:03:07.380 回答