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