Basic knowledge of IOS development-fragment 26, basic knowledge of ios-26

Source: Internet
Author: User

Basic knowledge of IOS development-fragment 26, basic knowledge of ios-26

1: UICollectionView scroll up and down if there is not enough data for one screen

When there is not much data and collectionView. contentSize is smaller than collectionView. frame. size, UICollectionView does not scroll. You can add the following code:

self.myCollectionView.alwaysBounceVertical = YES;

 

2: Draw the dotted line CGContextSetLineDash (vertical and horizontal)

Vertical: UIImageView * imageView1 = [[UIImageView alloc] initWithFrame: CGRectMake (10,100, 10,100)]; [self. view addSubview: imageView1]; UIGraphicsBeginImageContext (imageView1.frame. size); // start to draw a line [imageView1.image drawInRect: CGRectMake (0, 0, imageView1.frame. size. width, imageView1.frame. size. height)]; CGContextSetLineCap (UIGraphicsGetCurrentContext (), kCGLineCapRound); // you can specify the end point of a line. float lengths [] = {2, 2}; CGContextRef line = rows, [UIColor blackColor]. CGColor); CGContextSetLineDash (line, 0, lengths, 2); // draw the dotted CGContextMoveToPoint (line, 10.0, 10.0 ); // start to draw a line (10 refers to the 10-50 height 40 after the start point of the imageView1y axis) CGContextAddLineToPoint (line, 10.0, 50.0); CGContextStrokePath (line); imageView1.image = trim ();
Horizontal: UIImageView * imageView1 = [[UIImageView alloc] initWithFrame: CGRectMake (0,100,320, 20)]; [self. view addSubview: imageView1]; UIGraphicsBeginImageContext (imageView1.frame. size); // start to draw a line [imageView1.image drawInRect: CGRectMake (0, 0, imageView1.frame. size. width, imageView1.frame. size. height)]; CGContextSetLineCap (UIGraphicsGetCurrentContext (), kCGLineCapRound); // you can specify the end point of a line. float lengths [] ={ 10, 5}; CGContextRef line = limit, [UIColor redColor]. CGColor); CGContextSetLineDash (line, 0, lengths, 2); // draw the dotted CGContextMoveToPoint (line, 0.0, 20.0); // start to draw a line (from 0 to 310 x axis) CGContextAddLineToPoint (line, 310.0, 20.0); CGContextStrokePath (line); imageView1.image = UIGraphicsGetImageFromCurrentImageContext ();

Note: The lengths value {10, 10} indicates that 10 points are drawn first, and then 10 points are skipped.

If the value of lengths is changed to {10, 20, 10}, 10 points are drawn first, 20 points are skipped, 10 points are drawn, and 10 points are skipped, draw 20 more points so repeatedly

 

3: remove the Black edge that comes with the system navigationBar (implemented in viewDidLoad)

- (void)viewDidLoad {    [super viewDidLoad];        [[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];    [[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];}

 

4: create multiple targets in the same Project of XCode

Assume that the original target name is A. We need to create A new target B1. right-click the original target and select duplicate. Xcode will copy A target object named A copy, generate A copy-info.plist and A copy of scheme2. rename a) rename A copy target, you can directly click target to modify, change to Bb) A copy-info.plist, default generated in the program environment root directory, that is,. xcodeproj directory of the same level, if you want to put in the layer (such as with the A-info.plist in the same level directory), you can first Delete the copy-info.plist index in Xcode, and then copy the file to the directory, rename the B-info.plist and add it to the project. In Build Settings of the Project, modify Info. the plist File option is the directory of the B-info.plist (relative path) so that you can see the Info page (that is, the B-info.plist) and then modify ProductName and Bundle identifier to make it another app. The Prefix Header Path depends on the actual needs. If two targets can share the same Prefix Header, you do not need to modify the path here. c) Modify scheme, on the side of the Stop button for debugging, we can select all the targets in this project for compilation. If no modification is made, the selected name here is A copy. In order to unify it with the new target, you also need to modify the name here. Click the scheme selection area, Select Manager Scheme, find A copy, and change it to the name you need. For example, the advantage of using duplicate for B is that if there are many similarities between the two targets, use duplicate, you can copy all the relevant settings, without having to make too many modifications to generate a new target, which will be different from the original target. Here we can define a pre-compiled macro, to distinguish different versions of code, pre-compiled Macros can be defined in the Build Settings Preprocessor Macros, for example, define the pre-compiled MACRO in the newly created target B, then, in the Code, use # if defined (MACRO) // code to be executed by target B # else // code to be executed by target A # endif to differentiate others: build Phases (the content of each target compilation, it should be noted that if you create target B and then add resources or files to, these resources are not automatically added in target B and need to be manually added.) 1. compile Sources: code file to be compiled 2. link Binary With Libraries library 3. copy Bundle Resources: Resources required for compilation. Each target can add or remove content as needed.

Related Article

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.