最近使用UIProgressView这个控件,设置了frame
UIProgressView *progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(0, progerssY, SCREEN_WIDTH, 1)];
progressView.tintColor = JzZCOLORRGB(95, 155, 248);
progressView.trackTintColor = [UIColor whiteColor];
[self.view addSubview:progressView];
以上代码发现高度没变,然后自己测试了,高度一直为2,但是达不到需求,需求高度为1,然后从网上找来代码,设置
//改变高度
CGAffineTransform transform = CGAffineTransformMakeScale(1.0f,0.5f); //缩放
这个方法的确是改变了progressView得高度为1,但是progressView得y值也改变,y会移动(2-progressViewH)/2,progressViewH为自己要设置的高度,结果又不符合需求
所以想到组合动画来实现,
//改变高度还让y值正确达到想要的位置
CGAffineTransform transform = CGAffineTransformMakeScale(1.0f,0.5f);//缩放,y值向下移动0.5
progressView.transform = CGAffineTransformTranslate(transform, 0, -1);//平移,y值向上移动0.5
以上都是以我想要的高度为1来设置的