底部的 UIWebView 黑色随着动画的增加而增加?
UIWebView black color at bottom increases with Animation?
有些帖子,UIWebView底部是黑色的,可以通过两种简单的方法解决。
1. Clear Background of UIWebView
2. Set Opaque to NO.
但是,这只能解决静态 UIWebView 的问题,它不会更改其框架或约束。
在我的例子中,我有一个 UIWebView,它非常简单地拖放到故事板 ViewController 的视图上。无继承。我将背景设置为清除并将不透明设置为否。
到目前为止看起来还不错。但是当我应用动画时,使用 Facebook POP 库
1. SetOpaque = YES, With Animation is clips the UIWebView's content showing black color.
2. SetOpaque = NO, With Animation is clips the UIWebView's content showing nothing (a View or something comes in front)
-(void) setConstraint {
_topConstraintValue = self.topConstraint.constant - 200;
NSLog(@"Value is UP %f " ,_topConstraintValue);
}
- (IBAction)animateUp:(UIButton *)sender {
[self setConstraint];
[VSAnimation popChangeConstraintForBasicAnimation:self.topConstraint begin:0.5 newConstant:_topConstraintValue withDuartion:0.5 isEaseInAnimation:NO withCompletionBlock:nil];
}
-(void) setConstraintDown {
_topConstraintValue = 0;
_topConstraintValue = self.topConstraint.constant;
NSLog(@"Value is Down %f " ,_topConstraintValue);
}
- (IBAction)animateDown:(UIButton *)sender {
[self setConstraintDown];
[VSAnimation popChangeConstraintForBasicAnimation:self.topConstraint begin:0.5 newConstant:[self getAnimatableConstraint:_topConstraintValue] withDuartion:0.5 isEaseInAnimation:NO withCompletionBlock:nil];
}
-(float)getAnimatableConstraint:(float)constant{
return constant+200.0;
}
-(float)getReverseAnimatableConstraint:(float)constant{
return constant-200.0;
}
其中,VS内部方法如下
//VSAnimation.m
+(void)popChangeConstraintForBasicAnimation:(NSLayoutConstraint *) layoutConstraintToPopChange begin:(float) beginTime newConstant:(CGFloat) newConstant withDuartion:(float)duration isEaseInAnimation:(BOOL)isEaseIn withCompletionBlock:(void (^)(POPAnimation *anim, BOOL finished)) completitionBlock{
NSString *key = [NSString stringWithFormat:@"constraints_changed_%@", layoutConstraintToPopChange];
POPBasicAnimation *basicAnim = [layoutConstraintToPopChange pop_animationForKey:key];
if(basicAnim){
basicAnim.toValue = @(newConstant);
basicAnim.completionBlock = completitionBlock;
}else{
basicAnim = [POPBasicAnimation animationWithPropertyNamed:kPOPLayoutConstraintConstant];
if(isEaseIn)
basicAnim.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
else
basicAnim.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
basicAnim.toValue = @(newConstant);
basicAnim.completionBlock = completitionBlock;
basicAnim.beginTime = [self timeWithDelay:beginTime];
basicAnim.delegate = self;
basicAnim.duration = duration;
[layoutConstraintToPopChange pop_addAnimation:basicAnim forKey:key];
}
}
底部的 line/transparent 黑线是什么。
如何在为 UIWebView 设置动画时阻止它增加。
图像:
正在显示向上动画和向下动画。
@VS,看了你的源码,发现第二个webview的constraint好像设置错了。在我去掉高度限制WV2.height = 0.095 * height
后,问题就消失了。您必须正确设置 WV2 的高度限制。
有些帖子,UIWebView底部是黑色的,可以通过两种简单的方法解决。
1. Clear Background of UIWebView
2. Set Opaque to NO.
但是,这只能解决静态 UIWebView 的问题,它不会更改其框架或约束。
在我的例子中,我有一个 UIWebView,它非常简单地拖放到故事板 ViewController 的视图上。无继承。我将背景设置为清除并将不透明设置为否。
到目前为止看起来还不错。但是当我应用动画时,使用 Facebook POP 库
1. SetOpaque = YES, With Animation is clips the UIWebView's content showing black color.
2. SetOpaque = NO, With Animation is clips the UIWebView's content showing nothing (a View or something comes in front)
-(void) setConstraint {
_topConstraintValue = self.topConstraint.constant - 200;
NSLog(@"Value is UP %f " ,_topConstraintValue);
}
- (IBAction)animateUp:(UIButton *)sender {
[self setConstraint];
[VSAnimation popChangeConstraintForBasicAnimation:self.topConstraint begin:0.5 newConstant:_topConstraintValue withDuartion:0.5 isEaseInAnimation:NO withCompletionBlock:nil];
}
-(void) setConstraintDown {
_topConstraintValue = 0;
_topConstraintValue = self.topConstraint.constant;
NSLog(@"Value is Down %f " ,_topConstraintValue);
}
- (IBAction)animateDown:(UIButton *)sender {
[self setConstraintDown];
[VSAnimation popChangeConstraintForBasicAnimation:self.topConstraint begin:0.5 newConstant:[self getAnimatableConstraint:_topConstraintValue] withDuartion:0.5 isEaseInAnimation:NO withCompletionBlock:nil];
}
-(float)getAnimatableConstraint:(float)constant{
return constant+200.0;
}
-(float)getReverseAnimatableConstraint:(float)constant{
return constant-200.0;
}
其中,VS内部方法如下
//VSAnimation.m
+(void)popChangeConstraintForBasicAnimation:(NSLayoutConstraint *) layoutConstraintToPopChange begin:(float) beginTime newConstant:(CGFloat) newConstant withDuartion:(float)duration isEaseInAnimation:(BOOL)isEaseIn withCompletionBlock:(void (^)(POPAnimation *anim, BOOL finished)) completitionBlock{
NSString *key = [NSString stringWithFormat:@"constraints_changed_%@", layoutConstraintToPopChange];
POPBasicAnimation *basicAnim = [layoutConstraintToPopChange pop_animationForKey:key];
if(basicAnim){
basicAnim.toValue = @(newConstant);
basicAnim.completionBlock = completitionBlock;
}else{
basicAnim = [POPBasicAnimation animationWithPropertyNamed:kPOPLayoutConstraintConstant];
if(isEaseIn)
basicAnim.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
else
basicAnim.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
basicAnim.toValue = @(newConstant);
basicAnim.completionBlock = completitionBlock;
basicAnim.beginTime = [self timeWithDelay:beginTime];
basicAnim.delegate = self;
basicAnim.duration = duration;
[layoutConstraintToPopChange pop_addAnimation:basicAnim forKey:key];
}
}
底部的 line/transparent 黑线是什么。 如何在为 UIWebView 设置动画时阻止它增加。
图像:
正在显示向上动画和向下动画。
@VS,看了你的源码,发现第二个webview的constraint好像设置错了。在我去掉高度限制WV2.height = 0.095 * height
后,问题就消失了。您必须正确设置 WV2 的高度限制。