如何突出显示文本域?

时间:2015-10-19 07:13:02

标签: ios ios7

如果在文本字段中没有写入任何内容,如何突出显示文本字段并在几秒钟后移除发光?

{{1}}

2 个答案:

答案 0 :(得分:0)

1.Import quartzcore framework

2.添加shadowopacity,shadowColor ......像这样,

_textField.layer.shadowOpacity = 1.0;   
_textField.layer.shadowRadius = 0.0;
_textField.layer.shadowColor = [UIColor blackColor].CGColor;
_textField.layer.shadowOffset = CGSizeMake(0.0, -1.0);

答案 1 :(得分:0)

#import <QuartzCore/QuartzCore.h>

textField.layer.masksToBounds = NO;
textField.layer.shadowColor = [[UIColor blueColor] CGColor];
textField.layer.shadowOffset = CGSizeZero;
textField.layer.shadowRadius = 10.0f;
textField.layer.shadowOpacity = 1.0;

如果您想在几秒钟后隐藏边框或阴影,请使用此代码..这一个用于2秒后更改,但您可以根据需要添加秒。

[NSTimer scheduledTimerWithTimeInterval:2.0
                             target:self
                           selector:@selector(doSomethingWhenTimeIsUp:)
                           userInfo:nil
                            repeats:NO];
- (void) doSomethingWhenTimeIsUp:(NSTimer*)t {

    // YES! Do something here that you want to hide after few seconds!!
     [textField setBorderStyle:UITextBorderStyleNone];

}
希望这个可以帮助你......