我正在尝试从 viewController 顶部的底部为 UIWebView 设置动画,并且我正在使用砌体(https://github.com/Masonry/Masonry)。
我最初创建大小为 0 -(x、y、高度和宽度)的 webview,然后尝试对其进行动画处理,以便 webview 在视图控制器的“顶部”进行动画处理。显示了 web 视图,但它没有就地动画 - 它只是立即出现。有经验的人可以指导我正确的方向吗?
这是我的按钮动作
-(void)didPressBtn{
self.infoView = [UIWebView new];
self.infoView.scalesPageToFit = YES;
self.infoView.backgroundColor = [UIColor whiteColor];
self.infoView.delegate = self;
[self.scrollView addSubview:self.infoView];
[self.infoView makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(@(0));
}];
[self.scrollView layoutIfNeeded];
//FIXME: Hmmm it doesn't really animate!?
[UIView animateWithDuration:1 animations:^{
[self.scrollView setContentOffset:CGPointMake(0, 0)];
[self.infoView makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.scrollView);
}];
[self.scrollView layoutIfNeeded];
} completion:^(BOOL finished) {
[self.infoView loadRequest:[[NSURLRequest alloc] initWithURL:[[NSURL alloc] initWithString:NSLocalizedString(@"INFORMATION_URL", )] cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:15]];
}];
}
我的 viewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
self.scrollView = [UIScrollView new];
self.scrollView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:self.scrollView];
[self.scrollView makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view);
}];
UIView *contentView = [UIView new];
[self.scrollView addSubview:contentView];
[contentView makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.scrollView);
make.width.equalTo(self.scrollView);
}];
//Then adding buttons and such...
}