Summary of development of dolphin community in stages

Source: Internet
Author: User

    1. Image filtering, loading and display processing
    2. Gesture Processing
    3. string handling, character escaping, property strings
    4. Time stamp Processing
    5. Review of simple animation effects
    6. Rich Text Framework recommended Ftcoretextview and Ftcoretextstyle
    7. Summary of other experiences

First, image screening, loading and display processing

1, load the network picture, using the uiimageview+afnetworking classification of the setting method Setimagewithurl.

2, Uiimageview important method Setcontentmode:

The Setcontentmode method, type Uiviewcontentmode, is divided into the following enumeration types:

Uiviewcontentmodescaletofill,

Uiviewcontentmodescaleaspectfit,//contents scaled to fit with fixed aspect. Remainder is transparent

Uiviewcontentmodescaleaspectfill,//contents scaled to fill with fixed aspect. Some portion of content may be clipped.

Uiviewcontentmoderedraw,//Redraw on Bounds change (calls-setneedsdisplay)

Uiviewcontentmodecenter,//contents remain same size. Positioned adjusted.

Uiviewcontentmodetop,

Uiviewcontentmodebottom,

Uiviewcontentmodeleft,

Uiviewcontentmoderight,

Uiviewcontentmodetopleft,

Uiviewcontentmodetopright,

Uiviewcontentmodebottomleft,

Uiviewcontentmodebottomright,

Scaletofill mode is full of the parent container, when the picture content and the container length and width ratio is inconsistent, the deformation will occur, scaleaspectfit means to adapt to the container scale, and then all the picture, and so on than scaling; Scaleaspectfill means filling the container, not compressing the picture, However, the picture may go beyond the container border and not show the out-of-section.

3, the important method of Uiimageview.layer Setcornerradius:

Set a radius to cut the display area into a circle. The methods used in conjunction with Setmaskstobounds and Setborderwidth are also available.

4, the important method of Uiimageview.layer Setshadowoffset:

Sets the offset position of the shadow effect, with the parameter cgsize,x positive for right and y as the next.

5, Uiimageview can set the Animationimages property, and then call the Startanimating method, play a group of pictures, forming an animation

6, stretching the picture: Sometimes, you need to adapt the image width or height, but can not be distorted, so need to use the picture stretching technology.

Can be implemented using UIImage's Resizableimagewithcapinsets:resizingmode: method. The first parameter represents a rectangular area, and the portion of the picture outside of the area does not change, and part of the area is extruded. The second parameter represents the pattern: extrude or Tile.

Special note: In the HD screen, the picture needs to use the @2x naming mode, otherwise the picture will be stretched and deformed.

Second, gesture

The Uigesturercognizer class is a gesture parent class with properties such as gesture State, delegate agreement, and so on. Gesture states are mainly divided into began,changed,ended,cancelled,failed and so on. You can set and get the minimum number of touch points required for gestures, and how many times to touch the active time.

As a more common and convenient subclass, there are several types of sub-categories:

UITapGestureRecognizer, indicating a click gesture

Uipinchgesturerecognizer, indicating a pinch gesture

Uipangesturerecognizer, indicating the drag gesture

Uiswapgesturerecognizer, says sweep hands

Uirotategesturerecognizer, indicating rotation gesture

Use Initwithtarget:action: The initial method, the action is selector to specify the method. The gesture is then added through the Addgesturerecognizer method of the target view. The proxy method is not implemented.

Click the tap gesture and you may encounter a situation where clicking and double-clicking coexist. A filtering process is required to handle the multi-click gesture first. The method is:

[Singletapgest Requiregesturerecognizertofail:doubletapgest];

Three, string processing

Before encountering more string processing work, this summarizes the important content.

1. MD5 encryption of strings:

Before use, add Reference #import <CommonCrypto/CommonDigest.h>

+ (NSString *) Md5hexdigest: (NSString *) input

{

if (0 = = input.length) {

return nil;

}

Const char* str = [input utf8string];

unsigned char result[cc_md5_digest_length];

CC_MD5 (str, strlen (str), result);

Nsmutablestring *ret

= [Nsmutablestring stringwithcapacity:cc_md5_digest_length*2];//

for (int i = 0; i<cc_md5_digest_length; i++) {

[ret appendformat:@ "%02x", Result[i]];

}

return ret;

}

2. Calculate the size of the string:

[Text boundingrectwithsize:cgsizemake (width, 0) options:

Nsstringdrawingtruncateslastvisibleline |

Nsstringdrawinguseslinefragmentorigin |

Nsstringdrawingusesfontleading Attributes:attribute Context:nil]

The attributes is used here, and the type is the nsdictionary that describes the character of the string attribute. Here's an example:

nsdictionary* attributedic = @{nsparagraphstyleattributename:paragraphstyle, nskernattributename: [NSNumber NUMBERWITHFLOAT:2.0F], Nsfontattributename:font (detailviewtextsize), Nsforegroundcolorattributename: Replycontentcolor};

In the example above, several types are involved:

Nsparagraphstyleattributename represents a paragraph style property.

nsmutableparagraphstyle* Paragraphstyle = [[Nsmutableparagraphstyle alloc] init];

Paragraphstyle.maximumlineheight = Perlineheight;

Paragraphstyle.minimumlineheight = Perlineheight;

paragraphstyle.linespacing = Perlineaddedheight;

paragraphstyle.paragraphspacing = Paragraphinsetheight;

Paragraphstyle.linebreakmode = nslinebreakbywordwrapping;

The above is a detailed set of paragraph styles.

Nskernattributename indicates font spacing, note for NSNumber type

The following two are the font type and font color, respectively.

Four, time stamp processing

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];

Set the default local time zone

[Formatter Settimezone:[nstimezone Defaulttimezone];

Set the time format

[Formatter setdateformat:@ "Yyyy-mm-dd HH:mm:ss"];

You can customize the time format, similar to the following

[Formatter setdateformat:@ "Yyyy-mm-dd 23:59:59"];

Five, animation effect

The main use of UIView animation block method:

+ (void) Transitionwithview: (UIView *) view

Duration: (nstimeinterval) Duration options: (uiviewanimationoptions) options

Animations: (void (^) (void)) animations

Completion: (void (^) (BOOL finished)) completion

Set the UIView for the animation or nil, animation period, animation type, animation content, animation after the completion of the content.

Six, Rich Text control research

Studies of Ftcoretextview and Ftcoretextstyle

Currently this framework is used in the search module to display hit keywords.

Usage:

First, the following method is used to instantiate the Ftcoretextview

[[Ftcoretextview Alloc]

Initwithframe:cgrectmake (Tableviewcellhorizonoffset, TABLEVIEWSECTIONTOPEDGE1, Screen_width- Tableviewcellhorizonoffset * 2, 23)];

Then add the Ftcoretextstyle object Addstyle

Ftcoretextstyle *namestyle = [[Ftcoretextstyle alloc] init];

Namestyle.font = FontBold (12);

Namestyle.color = Color (108, 96, 84, 1.0);

Namestyle.textalignment = Ftcoretextalignementleft;

[Self.postname Addstyle:namestyle];

The framework is also powerful, you can customize similar XML tags to define the corresponding text style, which can also be paragraph spacing and line spacing, but the only way to adjust the font spacing. So in order to adjust the font spacing, using the Font property style string to display, which leads to incompatible with the display of XML tags, it is not used in the post details of the framework.

Vii. Summary of other experiences

1, the use of Arc management content, you need to exit the controller, the UIView with Subview all sub-view all removed, and the variables and attributes are set to nil

2. After adding an object to an array, you can set it to nil in time.

3, Uiimageview can only display static and picture arrays, can not display jif format picture

4, Tableheaderview and Tablefooterview need to be instantiated before you can add view

5. It is best to put the operation for updating the interface in the following block

Dispatch_async (Dispatch_get_main_queue ()), ^{

});

6, the Nstimer class method, has started the timer, does not need to call the instance method fire, may cause the conflict. When not in use, it is necessary to call invalidate to stop the timer, preferably with nil at the end.

7. It is best to put the operation for updating the interface in the following block

Dispatch_async (Dispatch_get_main_queue ()), ^{

});

Summary of development of dolphin community in stages

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.