IOS learning and ios learning routes

Source: Internet
Author: User

IOS learning and ios learning routes

Ideas:

1. A new Empty file is suffixed with A. txt file, and the content is copied at will.

2. Use NSString to receive local files and splice strings with a title

3. Create an NSMutableParagraphStyle instance and set the interval between the title center and the title and the body.

4. Create an NSMutableParagraphStyle instance and set the left alignment of the body and the indentation at the beginning of each segment to 10.

5. Create a basic animation instance and use a proxy to listen to the animation.

Let's talk about the code.

# Pragma mark -- concatenated character-(void) loadData :( NSString *) filename {// The first section NSMutableParagraphStyle * first = [[NSMutableParagraphStyle alloc] init]; first. alignment = NSTextAlignmentCenter; first. lineSpacing = 10; // The second section NSMutableParagraphStyle * second = [[NSMutableParagraphStyle alloc] init]; // writes second from the left. alignment = NSTextAlignmentLeft; // The first line indent second. firstLineHeadIndent = 10; // interval second. lineSpacing = 10; UIFont * titleFont = [UIFont systemFontOfSize: 16]; UIFont * contextFont = [UIFont systemFontOfSize: 13]; Limit * str1 = [NSMutableAttributedString alloc] initWithString: @ "game license and service agreement" attributes: @ {NSParagraphStyleAttributeName: first, NSFontAttributeName: titleFont}]; // The title is spliced into the text, with the line break NSString * str = [NSString stringWithFormat: @ "\ n % @", filename]; NSMutableAttributedString * str2 = [[NSMutableAttributedString alloc] initWithString: str attributes :@: second, NSFontAttributeName: contextFont}]; [str1 appendAttributedString: str2]; _ textView. attributedText = str1 ;}# pragma mark -- disable animation-(void) closeAniamtion :( UIView *) view {CABasicAnimation * animation = [CABasicAnimation animation]; animation. keyPath = @ "transform. scale "; animation. toValue = @ 0.9; animation. duration = 0.4; animation. delegate = self; animation. removedOnCompletion = NO; animation. fillMode = kCAFillModeForwards; [view. layer addAnimation: animation forKey: @ "closeAnimation"] ;}# pragma mark-local txt file content-(NSString *) filename {// NSString * path of the local txt file = [[NSBundle mainBundle] pathForResource: @ "in case of an emergency, there is no such thing as. txt" ofType: nil]; // retrieve the content NSString * filename = [[NSString alloc] initWithContentsOfFile: path encoding: NSUTF8StringEncoding error: nil]; return filename ;}
# Pragma mark -- the agent listens to the animation stop-(void) animationDidStop :( CAAnimation *) anim finished :( BOOL) flag {if ([_ bgView. layer animationForKey: @ "closeAnimation"] = anim) {[_ bgView removeFromSuperview];}

Complete code is available on github. Click here to download

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.