日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

全局异步和主线程异步区别、改变PlaceHolder颜色、解决键盘弹起挡住文本框问题...

發(fā)布時間:2024/6/21 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 全局异步和主线程异步区别、改变PlaceHolder颜色、解决键盘弹起挡住文本框问题... 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1、全局異步執(zhí)行耗時任務

dispatch_async(dispatch_get_global_queue(0, 0), ^{

});

2.主線程異步刷新UI

dispatch_async(dispatch_get_main_queue(), ^{

});

3.改變PlaceHolder的顏色

[username_text setValue:[UIColor colorWithRed:1 green:1

blue:1 alpha:0.5]

forKeyPath:@"_placeholderLabel.textColor"];

4.解決鍵盤彈起擋住文本框的問題

//鍵盤彈起時重置View大小

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent

*)event{

[username_text resignFirstResponder];

[password_text resignFirstResponder];

NSTimeInterval animationDuration = 0.30f;

[UIView beginAnimations:@"ResizeForKeyboard"context:nil];

[UIView setAnimationDuration:animationDuration];

CGRect rect = CGRectMake(0.0f, 0.0f,self.view.frame.size.width,self.view.frame.size.height);

self.view.frame = rect;

[UIView commitAnimations];

}

?

?

//退出編輯(鍵盤落下)重置View大小

- (BOOL)textFieldShouldReturn:(UITextField *)textField

{

NSTimeInterval animationDuration = 0.30f;

[UIView beginAnimations:@"ResizeForKeyboard"context:nil];

[UIView setAnimationDuration:animationDuration];

CGRect rect = CGRectMake(0.0f, 0.0f,self.view.frame.size.width,self.view.frame.size.height);

self.view.frame = rect;

[UIView commitAnimations];

[textField resignFirstResponder];

return YES;

}

?

5.開始編輯(鍵盤彈起)通過控件Y坐標計算View顯示范圍

- (void)textFieldDidBeginEditing:(UITextField *)textField

{

CGRect frame = password_text.frame;

int offset = frame.origin.y + 32 -

(self.view.frame.size.height - 216.0);

NSTimeInterval animationDuration = 0.30f;

[UIView beginAnimations:@"ResizeForKeyBoard"

context:nil];

[UIView setAnimationDuration:animationDuration];

floatwidth =self.view.frame.size.width;

floatheight =self.view.frame.size.height;

if(offset > 0)

{

CGRect rect = CGRectMake(0.0f, -

offset,width,height);

self.view.frame = rect;

}

[UIView commitAnimations];

}

轉載于:https://www.cnblogs.com/CJH5209/p/6072129.html

總結

以上是生活随笔為你收集整理的全局异步和主线程异步区别、改变PlaceHolder颜色、解决键盘弹起挡住文本框问题...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。