//1. A program that creates UI controls often calls the method to perform initialization. Therefore, if you need to perform some extra initialization on the UI control, you can do so by overriding the method.
-(instancetype) initWithFrame: (cgrect) frame
{
self = [super initwithframe: frame];
if (self) {
}
return self ;
}
//2. The method is called automatically after the program has loaded the control through the nib file. Therefore, if the program needs to perform a custom initialization after the control is loaded in the nib file, it can be implemented by overriding the method meter.
-(instancetype) Initwithcoder: (nscoder *) coder
{
self = [super initwithcoder: coder];
if (self) {
}
return self ;
}
//3. If your program needs to draw the contents of the control itself, you can do so by overriding the method.
-(void) DrawRect: (cgrect) rect
{
}
4. If your program needs more precise control over the layout of the child controls that the control contains, you can override the method implementation.
-(void) layoutsubviews
{
[Super layoutsubviews];
}
//5. The method is fired when the control adds a child control to completion.
-(void) Didaddsubview: (UIView *) subview
{
[Super didaddsubview: subview];
}
//6. The method is fired when the control is about to delete the child control.
-(void) Willremovesubview: (UIView *) subview
{
[Super willremovesubview: subview];
}
7. This method is fired when the control is added to the parent control when it is finished.
-(void) Didmovetosuperview
{
[Super Didmovetosuperview];
}
8. This method is fired when the control is added to the window to complete.
-(void) Didmovetowindow
{
[Super Didmovetowindow];
}
9. The method is fired when the user's finger starts to touch the control.
-(void) Touchesbegan: (nsset *) touches withevent: (uievent *) event
{
}
10. The method is fired when the user's finger moves on the control.
-(void) touchesmoved: (nsset *) touches withevent: (uievent *) event
{
}
11. the control is fired when the user's finger ends and moves on the control.
-(void) touchesended: (nsset *) touches withevent: (uievent *) event
{
}
12. the control fires when the user cancels the control.
-(void) touchescancelled: (nsset *) touches withevent: (uievent *) event
{
}
6. How to rewrite UIView?