//pop到底个之前的第x页面
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES];
//跳转到该应用的系统设置
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if([[UIApplication sharedApplication] canOpenURL:url]) {
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];
}
//设置父视图透明度而不影响子视图
view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
//改变textfield占位字颜色
[textField setValue:[UIColor greenColor] forKeyPath:@"_placeholderLabel.textColor"];
//修改textField字间距
NSDictionary *attrsDictionary = @{NSFontAttributeName: textField.font,
NSKernAttributeName:[NSNumber numberWithFloat:10.0f]};
textField.attributedText=[[NSAttributedString alloc]initWithString:textField.text
attributes:attrsDictionary];
//textview光标在第一行
self.automaticallyAdjustsScrollViewInsets = NO;
//给view某个角设置圆角
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:_confirmButton.bounds
byRoundingCorners:(UIRectCornerBottomLeft | UIRectCornerBottomRight)
cornerRadii:CGSizeMake(5,5)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = _confirmButton.bounds;
maskLayer.path = maskPath.CGPath;
_confirmButton.layer.mask = maskLayer;
//限制中英文字符串长度
- (int)convertToInt:(NSString *)strtemp {
int strlength = 0;
charchar *p = (char*)[strtemp cStringUsingEncoding:NSUnicodeStringEncoding];
for (int i=0 ; i<[strtemp lengthOfBytesUsingEncoding:NSUnicodeStringEncoding]; i++) {
if (*p) {
p++;
strlength++;
} else {
p++;
}
}
return (strlength+1)/2;
}
//判断字符串是否为纯数字
if (![self isPureInt:self.inputTextField.text]) {
WBShowToastMessage(@"请输入正确的QQ号");
return;
}
- (BOOL)isPureInt:(NSString*)string{
NSScanner *scan = [NSScanner scannerWithString:string];
int val;
return [scan scanInt:&val] && [scan isAtEnd];
}
// 密码不能包含中文或者中文符号
for (int i = 0; i < _userPwdTextField.text.length; i++) {
NSRange range = NSMakeRange(i, 1);
NSString *subString = [_userPwdTextField.text substringWithRange:range];
const charchar *cString = [subString UTF8String];
if (strlen(cString) == 3) {
[self shake:_pwdBgImage];
_reminderLabel.text = @"密码不能包含中文或者中文符号";
_reminderLabel.textColor = ReminderColor; return;
}
}
网友评论