IOS development-UI from entry to entry (2), ios-ui
IOS development-UI from entry to mastery (2) is the consolidation of iOS development-UI from entry to mastery (1) knowledge points, mainly focusing on exercise exercises and enhancing practical experience, lay a solid foundation for future development!
※Development environment and precautions:
1. In the early stage of iOS-UI development, we need to manually manage the memory, so we need to turn off the ARC (the steps for Xcode to turn off the ARC );
(1) Open Xcode and select the current project:
(2) Select Build Settings:
(3) Enter count in the input box:
(4) select Objective-C Automatic Reference Counting to set it to NO:
(5) In the AppDelegate. h file, change @ property (assign, nonatomic) UIWindow * window to @ property (retain, nonatomic) UIWindow * window;
(6) rewrite the AppDelegate. m file:-(void) dealloc {[_ window release]; [super dealloc];}
2. during development, we will use the simulator. Next let's take a look at the steps for adding the simulator (in the Xcode environment );
(1) Open the Devices in Xcode Window:
(2) Click "+" and select the Simulator Name in the displayed selection box:
Exercise 1: Create an Empty Application project and change the background color of the window to red;
※Code (left) and simulator running effect (right)
Exercise 2: create two views based on Exercise 1. set a background color to yellow (yellowView), and a background color to green (greenView); 2. add the view to the window;
※Code (left) and simulator running effect (right)
Exercise 3: Add greenView to yellowView Based on Exercise 2 and analyze the result;
※Code (left) and simulator running effect (right)
Exercise 4: Modify the greenView center and analyze the result based on Exercise 3;
※Code (left) and simulator running effect (right)
Exercise 5: Create a project and create five Views (aView, bView, cView, dView, and eView)
1. Use addSubview for window: Add aView and bView successively;
2. In window, use insertSubview: atIndex: to add the cView to the aView and bView;
3. The window uses insertSubview: aboveSubview: Method to add the dView to aView;
4. In window, use insertSubview: belowSubview: to add the eView to the bView;
※Code (left) and simulator running effect (right)
Exercise 6: Create a project, create a view, and add it to the window;
1. Test the hidden attribute;
2. Test the alpha attribute;
3. Test the attributes of superview and subviews;
4. Test tag attributes and viewWithTag: method;
※Code (left) and simulator running effect (right)
The next article will continuously update related knowledge points and exercises;
Email: dingding3w@126.com