任何对象的者有一个生命周期,即都存在一个实例化到销毁的过程。
UIView对象也不例外,那么UIView从init/new开始后,直到dealloc结束的过程中都经历了哪些过程呢?
首先自定义继承自UIView的对象LifeView
#import <UIKit/UIKit.h>
@interface LifeView : UIView
@end
#import "LifeView.h"
@interface LifeView ()
{
NSInteger count;
}
@end
@implementation LifeView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
NSLog(@"<-- 1 %s , count = %@-->", __func__, @(count++));
}
return self;
}
- (void)willMoveToSuperview:(nullable UIView *)newSuperview
{
NSLog(@"