• Shows or hides files in Finder

If you want to open the hidden files of the entire system, you can enter the following command in terminal: Finder AppleShowAllFiles -bool True Disables the display and hiding function. Defaults Write com.apple.finder AppleShowAllFiles -bool false killall Finder Restarts the Finder

  • Use the terminal to query the total lines of code

Use terminal command to enter the folder where the project is located and enter it in terminal

find . "(" -name "*.m" -or -name "*.strings" -or -name "*.h" ")" -print | xargs wc -l
Copy the code

Press Enter to query it

  • Rich text changes the color of different areas of text

In UILabel, UITextView, UITextField and other controls, there is an attributedText keyword, which is actually rich text. It’s an NSAttributedString, which is a class that has methods for changing the size, color, and other attributes of different paragraphs of text. Rich text is a string that can change properties…

NSAttributedString followed NSCopying, NSMutaleCopying and NSSecureCoding agreement. The corresponding methods can be implemented through the proxy, and this property will not be detailed here.

As shown in the figure above, we can use NSString to initialize a rich text, or we can initialize a string with a text attribute, or we can initialize a string with a character text.

The most important parameter in NSAttributedString

_subtitleLab.text = [NSString stringWithFormat:@"% @",[_myDict objectForKey:@"subtitle"]];
    _subtitleLab.width = SCREENWIDTH-20;
 *attStr = [[NSMutableAttributedString alloc] initWithString:_subtitleLab.text];
    NSArray *arr = [_subtitleLab.text componentsSeparatedByString:@":"];
    NSString *firstStr = arr[0];
//    [attStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(_subtitleLab.text.length-secondStr.length, secondStr.length)];
    [attStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#ef8c55"] range:NSMakeRange(0, firstStr.length)];
    _subtitleLab.attributedText = attStr;
Copy the code
  • Two-dimensional code scanner in the middle of the line rolling back and forth animation

UIView *line = [[UIImageView alloc] initWithFrame: CGRectMake (60, the self view. Bounds. The size, height / 2.0 – self. The width + 190, the self. The width – 120, 2)];

line.backgroundColor = [UIColor colorWithHexString:@”62bb46″]; [self.view addSubview:line ]; Delay > [UIView animateWithDuration: 2.5:0.0 the options: UIViewAnimationOptionRepeat animations: ^ {line. The frame = CGRectMake (60, the self view. Bounds. The size, height / 2.0 + 80, the self. The width – 120, 2);} completion: nil];

  • Resize the image
Copy the code

UIGraphicsBeginImageContext(size); [img drawInRect:CGRectMake(0, 0, size.width, size.height)]; UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return scaledImage; } ` ` `

  • screenshots
Copy the code

-(void)fullScreenshots{ UIWindow *screenWindow = [[UIApplication sharedApplication] keyWindow]; UIGraphicsBeginImageContext(screenWindow.frame.size); / / print screen, including window [screenWindow layer renderInContext: UIGraphicsGetCurrentContext ()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil); } ` ` `

  • SDWebImage realizes the fuzzy loading of image gradually and gradually
Copy the code

[_photoImageView sd_setImageWithURL:[NSURL URLWithString:myParser.kv_photoStr] placeholderImage:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { SDWebImageManager *manager = [SDWebImageManager sharedManager]; If ([manager diskImageExistsForURL: [NSURL URLWithString: myParser. Kv_photoStr]]) {NSLog (@ “no loading animation”); }else {_photoimageView.alpha = 0.0; [UIView transitionWithView: _photoImageView duration: 1.0 options: UIViewAnimationOptionTransitionCrossDissolve Animations :^{[_photoImageView setImage:image]; _PhotoImageView. alpha = 1.0;} completion:NULL];}}]; animations:^{[_photoImageView setImage:image]; _PhotoImageView. alpha = 1.0;} completion:NULL];}}]; ` ` `

  • UISegmentContrl changes the text color and size on Index
Copy the code

NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName, [UIFont systemFontOfSize:17],NSFontAttributeName, nil]; [segmentedCtrl setTitleTextAttributes:dic forState:UIControlStateSelected];

NSDictionary *dic1 = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor],NSForegroundColorAttributeName, [UIFont systemFontOfSize:17],NSFontAttributeName, nil]; [segmentedCtrl setTitleTextAttributes:dic1 forState:UIControlStateNormal]; ` ` `

  • Checking Camera Permissions
Copy the code

#pragma Mark – Check camera permissions

  • (BOOL)canUserCamear{ AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; If (authStatus = = AVAuthorizationStatusDenied) {UIAlertView * alertView = [[UIAlertView alloc] initWithTitle: @ “please open the camera permission” Message :@” settings-privace-camera “Delegate :self cancelButtonTitle:@” Confirm” otherButtonTitles:@” cancel “, nil]; alertView.tag = 100; [alertView show]; return NO; } else{ return YES; } return YES; }
- Get textField > ' 'UITextField *txfSearchField = [searchBar valueForKey:@"_searchField"];
Copy the code
  • Resolve gesture conflict with UIButton
Copy the code
  • (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { if ([touch.view isKindOfClass:[UIButton class]]){ return NO; } return YES; }
[remember some skills] (HTTP: / / http://mp.weixin.qq.com/s?__biz=MjM5OTM0MzIwMQ==&mid=2652547085&idx=1&sn=549e63eb5c6a7e62ce16bc835e3fbc8b&scene= 0#wechat_redirect)
Copy the code