我正在尝试使用stretchableImageWithLeftCapWidth调整图像大小:它在模拟器上工作,但在设备上,会出现垂直绿条.
我试图使用imageNamed,imageWithContentOfFile和imageWithData lo加载图像,它没有改变.
UIImage *bottomImage = [[UIImage imageWithData:
[NSData dataWithContentsOfFile:
[NSString stringWithFormat:@"%@/bottom_part.png",
[[NSBundle mainBundle] resourcePath]]]]
stretchableImageWithLeftCapWidth:27 topCapHeight:9];
UIImageView *bottomView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 200+73, 100, 73)];
[self.view addSubview:bottomView];
UIGraphicsBeginImageContext(CGSizeMake(100, 73));
[bottomImage drawInRect:CGRectMake(0, 0, 100, 73)];
UIImage *bottomResizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
bottomView.image = bottomResizedImage;
Run Code Online (Sandbox Code Playgroud)
看到结果:绿色条不应该在那里,它们不会出现在模拟器上.
替代文字http://www.quicksnapper.com/files/5161/96232162149F1C14751048_m.png
#include <stdio.h>
int main()
{
int a = 10;
if (a == a--)
printf("TRUE 1\t");
a = 10;
if (a == --a)
printf("TRUE 2\t");
}
Run Code Online (Sandbox Code Playgroud)
为什么第二个if语句是真的?
输出为:TRUE 1 TRUE 2
这是否由于未定义的行为而发生,因为我将相同的变量与其递减的值进行比较?
我想连续使用旋转图层byValue
,但我无法使其正常工作.我想每秒旋转6度,在60秒内完全旋转.
如果图层的初始旋转为0,则一切正常.
问题是当我尝试设置初始值时fromValue
.如果我设置fromValue
为90度,动画将从90度旋转到90 + 6,然后跳转到90+(90 + 6),动画和再次跳转.
任何的想法?
CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.fromValue = [NSNumber numberWithDouble:M_PI_2];
animation.byValue = [NSNumber numberWithDouble:6.0f*M_PI/180.0f];
animation.toValue = nil;
animation.fillMode = kCAFillModeForwards;
animation.cumulative = YES;
animation.additive = NO;
animation.repeatCount = 10000;
animation.removedOnCompletion = YES;
animation.duration = 1.0;
[myLayer addAnimation:animation forKey:@"transform"];
Run Code Online (Sandbox Code Playgroud)