图片的拉伸
2手机号
3邮箱
ios推送通知设置
向苹果注册推送通知
- UIImage *img=[UIImage imageNamed:@"imag"];
- img=[img stretchableImageWithLeftCapWidth:15 topCapHeight:12];
- UIImageView *imgView=[[UIImageView alloc]initWithImage:img];
- [imgView setFrame:CGRectMake(10, 10, 200, 200)];
- [self. view addSubview
- 这里用的图片拉伸方法
- (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight;
leftCapWidth是指leftCapWidth后面的一个想像素开始拉伸,topCapHeight距离topCapHeight的像素开始拉升
字体加粗 :[uifont boldSystemFontOfsize:20];
1身份证号
- + (BOOL) validateIdentityCard: (NSString *)identityCard
- {
- BOOL flag;
- if (identityCard.length <= 0) {
- flag = NO;
- return flag;
- }
- NSString *regex2 = @"^(\\d{14}|\\d{17})(\\d|[xX])$";
- NSPredicate *identityCardPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex2];
- return [identityCardPredicate evaluateWithObject:identityCard];
- }
- + (BOOL) validateMobile:(NSString *)mobile
- {
- //手机号以13, 15,18开头,八个 \d 数字字符
- NSString *phoneRegex = @"^((13[0-9])|(15[^4,\\D])|(18[0,0-9]))\\d{8}$";
- NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
- return [phoneTest evaluateWithObject:mobile];
- }
- + (BOOL) validateEmail:(NSString *)email
- {
- NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
- NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
- return [emailTest evaluateWithObject:email];
- }
先要配置好相应的证书,之后
在APPDelegate文件中设置
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- {
- ......
- //消息推送注册
- [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeSound|UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge];
- //判断程序是不是由推送服务完成的
- if (launchOptions) {
- NSDictionary* pushNotificationKey = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
- if (pushNotificationKey) {
- UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"推送通知"
- message:@"这是通过推送窗口启动的程序,你可以在这里处理推送内容"
- delegate:nil
- cancelButtonTitle:@"知道了"
- otherButtonTitles:nil, nil nil];
- [alert show];
- }
- }
- ......
- }
实现推送通知代理
- #pragma mark ------------- 消息推送代理 -----------------
- - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
- // NSString *token = [NSString stringWithFormat:@"%@", deviceToken];
- NSString *token=[[deviceToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
- token=[[token description] stringByReplacingOccurrencesOfString:@" " withString:@""];
- // user_defaults_set_string(@"deviceToken",STRING_FORMAT(@"%@",token));
- //获取终端设备标识,这个标识需要通过接口发送到服务器端,服务器端推送消息到APNS时需要知道终端的标识,APNS通过注册的终端标识找到终端设备。
- NSLog(@"My token is---------:%@", token);
- }
- - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
- NSString *error_str = [NSString stringWithFormat: @"%@", error];
- NSLog(@"Failed to get token, error:%@", error_str);
- }
- -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
- {
- /**********震动****************/
- AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)
- /**********提示音****************/
- AudioServicesPlaySystemSound(107);
- //在此处理接收到的消息。
- NSLog(@"Receive remote notification ------------------ : %@",userInfo);
- /************处理消息************/
- }