标签:自己 options current tde manage 保存 ack return mutable
#pragma mark - 单例方法(完整的方法)
系统的单例方法名称 sharedApplication defaultManager standardUserDefaults currentDevice
[UIApplication sharedApplication];
[NSFileManager defaultManager];
[NSUserDefaults standardUserDefaults];
[UIDevice currentDevice];
+ (instancetype)sharedInstace;
// 用来保存唯一的单例对象
static id _instace;
+ (id)allocWithZone:(struct _NSZone *)zone
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_instace = [super allocWithZone:zone];
});
return _instace;
}
+ (instancetype)sharedInstace
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_instace = [[self alloc] init];
});
return _instace;
}
- (id)copyWithZone:(NSZone *)zone
{
return _instace;
}
- (id)retain { return self; }
- (oneway void)release { }
- (id)autorelease { return self;}
- (NSUInteger)retainCount { return 1;}
#pragma mark--蒙板(遮罩层)
//1、添加蒙板(遮罩)
UIButton * coverButton = [[UIButton alloc] initWithFrame:self.view.bounds];
coverButton.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.5];
[coverButton addTarget:self action:@selector(tapcoverButton:) forControlEvents:UIControlEventTouchUpInside];
coverButton.alpha = 0.0;
[self.view addSubview:coverButton];
//2、将需要放大的图像按钮弄到最前面
//bringSubviewToFront
[self.view bringSubviewToFront:self.iconButton];
//3、动画放大图像按钮
CGFloat width = self.view.bounds.size.width;
CGFloat height = width;
CGFloat y = (self.view.bounds.size.height - height) * 0.5;
[UIView animateWithDuration:1.0 animations:^{
self.iconButton.frame = CGRectMake(0, y, width, height);
coverButton.alpha = 1.0;
}];
[UIView animateWithDuration:1.0 animations:^{
//将图像恢复初始位置
self.iconButton.frame = CGRectMake(112, 125, 150, 150);
button.alpha = 0.0;
} completion:^(BOOL finished) {
//动画完成之后,删除cover
[button removeFromSuperview];
}];
#pragma mark -- 查找子类方法
/*
+ (NSArray *)findAllSubClassofClass:(Class)superClass
OC 运行时方法
int count = objc_getClassList(NULL, 0);
NSMutableArray *output = [NSMutableArray array];
if (count <= 0)
{//发生错误或者没有子类
@throw @"Couldn‘t retrieve Obj-C class-list";
return output;
}
Class *classes = (__unsafe_unretained Class *)malloc(sizeof(Class) * count);
count = objc_getClassList(classes, count);
for (int i = 0; i < count; ++i)
{
if (superClass == class_getSuperclass(classes[i]))//子类
{
[output addObject:classes[i]];
}
}
//释放C 语言的对象
free(classes);
return output;
*/
#pragma mark - 自己封装刷新控件
/*
KVO 监听父视图的contentOffset
scrollView.addObserver(self, forKeyPath: "contentOffset", options: [], context: nil)
// 本视图从父视图上移除
// 提示:所有的下拉刷新框架都是监听父视图的 contentOffset
// 所有的框架的 KVO 监听实现思路都是这个!
override func removeFromSuperview() {
// superView 还存在
superview?.removeObserver(self, forKeyPath: "contentOffset")
super.removeFromSuperview() //在这句话之前移除监听
// superView 不存在
}
// 观察者模式,在不需要的时候,都需要释放
// - 通知中心:如果不释放,什么也不会发生,但是会有内存泄漏,会有多次注册的可能!
// - KVO:如果不释放,会崩溃!
*/
有任何关于iOS开发的问题!欢迎下方留言!!!或者邮件lieryangios@126.com 虽然我不一定能够解答出来,但是我会请教iOS开发高手!!!解答您的问题!!!
标签:自己 options current tde manage 保存 ack return mutable
原文地址:http://www.cnblogs.com/CoderEYLee/p/6808185.html