UIProgressView的使用
??? 最近使用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來設置的
?
轉載于:https://www.cnblogs.com/xingxiaoxiao/p/10234824.html
總結
以上是生活随笔為你收集整理的UIProgressView的使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: H5移动端开发学习总结
- 下一篇: (轉貼) Embedded System