step1.
全域宣告
UIButton *barBlockBut;
像是如下:
@interface SportViewController () <UITextFieldDelegate>
{
UIButton *barBlockBut;
}
step2.
調用textFieldDidBeginEditing
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
if(textField == (sportTimeTextField 這裡填寫您輸入的textField))
{
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
self.view.window.tintAdjustmentMode = UIViewTintAdjustmentModeDimmed;
}
barBlockBut = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
[self.navigationController.navigationBar addSubview:barBlockBut];
}
}
step3.
- (void)textFieldDidEndEditing:(UITextField *)textField
{
if(barBlockBut)
{
[barBlockBut removeFromSuperview];
barBlockBut = nil;
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
self.view.window.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;
}
}
}
ps:
記得 該UITextField 要設定
TextField.delegate = self;
ps:
記得 該UITextField 要設定
TextField.delegate = self;
0 意見:
張貼留言