【发布时间】:2015-02-05 12:20:18
【问题描述】:
我使用此代码将视图向上移动并在键盘出现时更改其颜色。
CGRect newFrame = CGRectMake(0, -self.bgImageView.frame.size.height + [UIApplication sharedApplication].statusBarFrame.size.height*1.4 self.width, self.height);
[UIView animateWithDuration:0.25 animations:^{
[self.view setFrame:newFrame];
self.overlay.backgroundColor = [UIColor clearColor];
}];
它适用于所有运行 iOS 7.1 和 iOS 8 的 iPhone 模拟器,但运行 iOS 7 的 iPhone 5 除外。颜色会发生变化,但视图不会向上移动。
【问题讨论】:
-
注意:不要在块内使用 self ,因为它可能会导致保留循环。例如:
__weak __typeof__(self) weakSelf = self; dispatch_group_async(_operationsGroup, _operationsQueue, ^ { [weakSelf doSomething]; } );
标签: ios objective-c iphone xcode animation