About iOS small points of knowledge

Source: Internet
Author: User

Because it is a random point of knowledge, not according to a certain aspect to write.


1. About Xcode6 Simulator keyboard does not eject with Command + Shift + K

2. About calling the Clipboard copy string

+ (void) Copytextwithstr: (NSString *) str {    Uipasteboard *pasteboard = [Uipasteboard Generalpasteboard];    Copy to clipboard    pasteboard.string = str;}

3. Set 16 color

+ (Uicolor *) Colorwithrgbhex: (UInt32) hex {int r = (hex >>) & 0xff;int g = (hex >> 8) & 0xff;int B = (hex) & 0xff;return [Uicolor colorwithred:r/255.0f   green:g/255.0fblue:b/255.0f   alpha:1.0f];}

4. Print Log

#define DLOG (FMT, ...) NSLog (@ "%s [line%d]" FMT), __pretty_function__, __line__, # #__VA_ARGS__);

5. Define Window/appdelegate

#define Application ([uiapplication sharedapplication]) #define WINDOW ([[UIApplication sharedapplication].windows Lastobject])


6. Set IOS6/IOS7. The height of the navigation bar

#define NAV_H 44#define top_y (ios_7 64:nav_h) #define TOP_TABLE_VIEW_H ((ios_7? 64:nav_h) + Nav_h)


7.UIImage Cutting Circle

+ (uiimage*) Circleimage: (uiimage*) Image withparam: (cgfloat) inset withframe: (cgrect) frame{cgimageref imageref = image .    Cgimage;    Cgimageref resultimgref = Cgimagecreatewithimageinrect (Imageref, frame);    UIImage *resultimg = [UIImage imagewithcgimage:resultimgref scale:image.scale orientation:image.imageOrientation];        Cgimagerelease (RESULTIMGREF);        Uigraphicsbeginimagecontext (resultimg.size); Cgcontextref context = Uigraphicsgetcurrentcontext ();//Cgcontextsetlinewidth (context, 1);//Cgcontextsetstrokecolor Withcolor (context, [Uicolor Clearcolor].    Cgcolor);        CGRect rect = CGRectMake (inset, inset, Resultimg.size.width-inset, Resultimg.size.height-inset);    Cgcontextaddellipseinrect (context, rect);        Cgcontextclip (context);    [Resultimg Drawinrect:rect];    Cgcontextaddellipseinrect (context, rect);//Cgcontextstrokepath (context);    UIImage *newimg = Uigraphicsgetimagefromcurrentimagecontext ();        Uigraphicsendimagecontext (); ReTurn newimg;} 


8.MD5 encryption

-(NSString *) MD5 {    const char *cstr = [self utf8string];    unsigned char result[16];    CC_MD5 (CStr, (UInt32) strlen (CSTR), result);    return [NSString stringWithFormat:            @ "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",            Result[0], result[1], result[2], result[3],            result[4], result[5], result[6], result[7],            result[8], result[9], RESULT[10], result[11],            result[12], result[13], result[14], result[15]            ];}




About iOS small points of knowledge

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.