zoukankan      html  css  js  c++  java
  • 判断邮箱格式和图片压缩

    1.判断邮箱格式

    -(BOOL)isValidateEmail:(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];

    }

    2.图片压缩

    UIImage *yourImage= [selfimageWithImageSimple:image

    scaledToSize:CGSizeMake(210.0, 210.0)];

    - (UIImage*)imageWithImageSimple:(UIImage*)image

    scaledToSize:(CGSize)newSize

    {

    Tell the old image to draw in this newcontext, with

    the desired

    new size

    [image

    drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];

    Get the new image from the context

    UIImage* newImage =

    UIGraphicsGetImageFromCurrentImageContext();

    Create a graphics image context

    UIGraphicsBeginImageContext(newSize);

    End the context

    UIGraphicsEndImageContext();

    Return the new image.

    returnnewImage;

    }

  • 相关阅读:
    OA项目之分页
    OA项目之弹出层中再弹出层
    OA项目之导入
    OA项目之导出
    git使用6步走
    配置 Docker 镜像站
    Taro随笔
    byte(C# 参考)
    MySQL 笔记
    HTTP 错误代码
  • 原文地址:https://www.cnblogs.com/CJH5209/p/6072148.html
Copyright © 2011-2022 走看看