@interface UIView (Zoom)
-(void)viewZoomMaxBounds:(CGRect) maxBounds minBounds:(CGRect) minBounds finallyBounds:(CGRect) finallyBounds;
@end
#import "UIView+Zoom.h"
@implementation UIView (Zoom)
-(void)viewZoomMaxBounds:(CGRect)maxBounds minBounds:(CGRect) minBounds finallyBounds:(CGRect)finallyBounds
{
[UIView animateWithDuration:0.3f animations:^{
self.bounds=maxBounds;
} completion:^(BOOL finished){
[UIView animateWithDuration:0.1f animations:^{
self.bounds=minBounds;
} completion:^(BOOL finished){
[UIView animateWithDuration:0.05f animations:^{
self.bounds=finallyBounds;
}completion:^(BOOL finished){
[[NSNotificationCenter defaultCenter] postNotificationName:@"finished" object:nil];
}];
}];
}];
}
@end
这是我写的一个category 增加uiview一个动画功能
registerView=[[RegisterView alloc] initWithFrame:CGRectMake(160, 197, 0, 0)];
NSLog(@"1:%i",registerView.retainCount);
registerView.delegate=self;
registerView.backgroundColor=[UIColor blackColor];
[self.view addSubview:registerView];
NSLog(@"2:%i",registerView.retainCount);
[registerView viewZoomMaxBounds:CGRectMake(0, 0, 320, 394) minBounds:CGRectMake(0, 0, 290, 360) finallyBounds:CGRectMake(0, 0, 300, 380)];
NSLog(@"3:%i",registerView.retainCount);
[registerView release];
NSLog(@"4:%i",registerView.retainCount);
[super viewDidAppear:animated];
这个是代码中的调用 先是创建一个view
可是调用了红色代码以后retaincount加一了,不知道为什么? 求高手指点
[registerView viewZoomMaxBounds:CGRectMake(0, 0, 320, 394) minBounds:CGRectMake(0, 0, 290, 360) finallyBounds:CGRectMake(0, 0, 300, 380)];
------解决方案--------------------
估计是在执行过程中所调用的方法执行了retain,然后又autorelease了吧,所以在当前方法完成前,你会发现多了一个retain计数,但实际上并没有什么影响。