亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

iOS虛擬鍵盤上添加動態按鈕

發布時間:2020-06-10 19:01:10 來源:網絡 閱讀:699 作者:新風作浪 欄目:移動開發


之前在 
iOS虛擬鍵盤上添加動態隱藏按鈕一文中描敘了關于鍵盤上添加動態按鈕的操作,發現鍵盤上的按鈕顯示出來的時候很僵硬,此處做了改進,添加了動畫過渡,更換了圖片,能夠讓人感覺按鈕是隨著鍵盤的動畫顯示而顯示,隨著鍵盤的動畫退出而退出,看上去更加流暢些;


效果圖:

iOS虛擬鍵盤上添加動態按鈕  iOS虛擬鍵盤上添加動態按鈕


iOS虛擬鍵盤上添加動態按鈕  iOS虛擬鍵盤上添加動態按鈕

 

 

- (void)viewDidLoad
{
    NSLog(@"%@",NSStringFromSelector(_cmd));
    [super viewDidLoad];
	exitButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [exitButton setImage:[UIImage p_w_picpathNamed:@"down.png"] forState:UIControlStateNormal];
    CGRect exitBtFrame = CGRectMake(self.view.frame.size.width-48, self.view.frame.size.height , 48.0f, 30.0f);
    
    [exitButton setFrame:exitBtFrame];
      
   
    [self.view addSubview:exitButton];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleKeyboardDidShow:) name:UIKeyboardWillShowNotification object:nil];  
    
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleKeyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
}

 

- (void)handleKeyboardDidShow:(NSNotification *)notification 
{
    NSLog(@"%@",NSStringFromSelector(_cmd));
    NSDictionary *info = [notification userInfo];
    NSLog(@"-->info:%@",info);
    CGRect keyboardFrame;
    [[info objectForKey:UIKeyboardFrameEndUserInfoKey] getValue:&keyboardFrame];
    CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey]CGRectValue].size;
    NSValue *animationDurValue = [info objectForKey:UIKeyboardAnimationDurationUserInfoKey];
    NSTimeInterval animationDuration;
//    copy value
    [animationDurValue getValue:&animationDuration];
    
//    讓鍵盤彈起的時候添加一個動畫
    [UIView beginAnimations:@"animal" context:nil];
    [UIView setAnimationDuration:animationDuration];
    
    CGFloat distanceToMove = kbSize.height;
    NSLog(@"---->動態鍵盤高度:%f",distanceToMove);
    [self adjustPanelsWithKeyBordHeight:distanceToMove];
    [UIView commitAnimations];
    exitButton.hidden=NO;
    [exitButton addTarget:self action:@selector(CancelBackKeyboard:) forControlEvents:UIControlEventTouchDown];
    

}

 

- (void)handleKeyboardWillHide:(NSNotification *)notification 
{
    NSLog(@"%@",NSStringFromSelector(_cmd));

    NSDictionary *info = [notification userInfo];
    CGRect keyboardFrame;
    [[info objectForKey:UIKeyboardFrameEndUserInfoKey] getValue:&keyboardFrame];
    NSValue *animationDurValue = [info objectForKey:UIKeyboardAnimationDurationUserInfoKey];
    NSTimeInterval animationDuration;
    //   把animationDurvalue 值拷貝到animationDuration中
    [animationDurValue getValue:&animationDuration];
    
    [UIView beginAnimations:@"animal" context:nil];
    [UIView setAnimationDuration:animationDuration];

    if (exitButton) {

        CGRect exitBtFrame = CGRectMake(self.view.frame.size.width - 48, self.view.frame.size.height, 48.0f, 30.0f);
        exitButton.frame = exitBtFrame;
        [self.view addSubview:exitButton];

    }
    [UIView commitAnimations];
    
}

 

-(void)adjustPanelsWithKeyBordHeight:(float) height
{
   
    NSLog(@"%@",NSStringFromSelector(_cmd));
    if (exitButton) {

       CGRect exitBtFrame = CGRectMake(self.view.frame.size.width - 48, self.view.frame.size.height - height-30, 48.0f, 30.0f);
        exitButton.frame = exitBtFrame;

        [self.view addSubview:exitButton];


    }
    
    
}

 

-(void)CancelBackKeyboard:(id)sender
{
    NSLog(@"%@",NSStringFromSelector(_cmd));
    
    [textField resignFirstResponder];
    
}


- (void)viewDidUnload
{
    [self setTextField:nil];
    exitButton=nil;
    [super viewDidUnload];
    
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

- (void)dealloc {
    [textField release];
    [exitButton release];
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [super dealloc];
}

 

 

 

源碼:http://download.csdn.net/detail/duxinfeng2010/4858444

 
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

社会| 泰顺县| 柯坪县| 上犹县| 三江| 乐亭县| 花垣县| 同仁县| 元江| 萨迦县| 盐源县| 商河县| 龙游县| 灌阳县| 会昌县| 奉贤区| 道真| 金堂县| 长兴县| 偏关县| 黔江区| 全椒县| 临颍县| 繁昌县| 安远县| 长宁县| 巫山县| 肃宁县| 多伦县| 苏尼特左旗| 陇南市| 英吉沙县| 桐柏县| 漳平市| 鄂托克前旗| 隆林| 南岸区| 洪泽县| 积石山| 沙河市| 鄯善县|