我已经创建了一个但是云形状。请帮助创建此
答案 0 :(得分:2)
对UITextField
进行子类,然后覆盖becomeFirstResponder
(显示气泡)和resignFirstResponder
(隐藏气泡),当字段处于活动状态时,会显示您的气泡。
<强>·H 强>
#import <UIKit/UIKit.h>
@interface BubbleTextField : UITextField
@end
<强>的.m 强>
#import "BubbleTextField.h"
@interface BubbleTextField ()
{
UIView *_bubbleView;
}
- (void)showBubble:(BOOL)show;
@end
@implementation BubbleTextField
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialize the _bubbleView here
}
return self;
}
#pragma mark - Override
- (BOOL)becomeFirstResponder {
BOOL shouldBecome = [super becomeFirstResponder];
if (shouldBecome)
{
[self showBubble:YES];
}
return shouldBecome;
}
- (BOOL)resignFirstResponder {
BOOL shouldResign = [super resignFirstResponder];
if (shouldResign)
{
[self showBubble:NO];
}
return shouldResign;
}
#pragma mark - Private Methods
- (void)showBubble:(BOOL)show {
// Show/Hide
// Animations etc.
}
@end
答案 1 :(得分:1)