One, add a new line
0. Remove the last child control
UIView *last = [Self.view.subviews lastobject];
New Y for this line = Last child control y + height of last child control
CGFloat rowy = last.frame.origin.y + lat.frame.size.height + 1; 1 for Line spacing
1. Create a row
UIView *rowview = [[UIView alloc] Initwithframe:cgrectmake (0, Rowy, 320, 50)];
* Equivalent to the following two lines
UIView *rowview = [[UIView alloc] init];
Rowview.frame = CGRectMake (0, Rowy, 320, 50);
Rowview.backgroundcolor = [Uicolor Redcolor]; Set Background color red
2. Add a row to the view in the controller
[Self.view Addsubview:rowview];
3. Make Delete Item valid
_removeitem.enabled = YES;
4. Performing animations
Rowview.frame = CGRectMake (Rowy, 320, 50);
Rowview.alpha = 0; Default transparency
4.1 Start animation
[UIView Beginanimations:nil Context:nil];
[UIView setanimationduration:1.0];
Rowview.frame = CGRectMake (0, Rowy, 320, 50);
Rowview.alpha = 1; Transparency changed to 1
[UIView commitanimations];
* Equivalent to the following animation block usage
[UIView animationwithduration:1.0 animation:∧{
Rowview.frame = CGRectMake (0, Rowy, 320, 50);
Rowview.alpha = 1; Transparency changed to 1
}];
Second, delete the last line
1. Remove the last child control
UIView *last = [Self.view.subviews lastobject];
Determines the property of the last class, which is toolbar return
Class C = [Uitoolbar class];
if ([last iskindofclass:c]) return;
2 Removing a child control
[Last Removefromsuperview];
[UIView animationwithduration:1.0 animations:∧{
CGRect Tempf = last.frame;
Tempf.origin.x = 320;
Last.frame = Tempf;
Last.alpha = 0;
} completion:∧ (BOOL finished) {
[Last Removefromsuperview];
_removeitem.enabled = Self.view.subviews.count >1;
}]
3. Determine the number of remaining child controls
if (Self.view.subviews.count = = 1)
{
_removeitem.enabled = No;
}
* Equivalent to the following line
_removeitem.enabled = Self.view.subviews.count >1;
2015-4-14 Study notes: Contact management