91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

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

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

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

江津市| 榆林市| 武邑县| 丹江口市| 兴义市| 阳曲县| 和田市| 甘洛县| 从江县| 宜丰县| 两当县| 寻乌县| 玛曲县| 博爱县| 九龙城区| 金寨县| 宕昌县| 临西县| 县级市| 瑞金市| 清镇市| 衡山县| 紫云| 饶阳县| 蛟河市| 铜山县| 宜昌市| 大理市| 无极县| 常熟市| 手机| 卢龙县| 永平县| 冷水江市| 雅安市| 宜州市| 防城港市| 上饶县| 察哈| 鹤山市| 彰化县|