Progress view height in iOS 7

爷,独闯天下 提交于 2019-11-27 20:28:48

问题


I want to increase the height of progress view in iOS 6 and below i am doing this using appearence method

  UIImage *progressImage = [[UIImage imageNamed:@"sliderbk-progress.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 4, 0, 5)];
[[UIProgressView appearance] setProgressImage:progressImage];

but now in iOS7 this code is not working i even try given below code but no use. Any help will be helpfull. Thanks

[[UIProgressView appearance] setFrame:CGRectMake(20, 100, 280, 100)];

回答1:


If I am understanding the question correctly it sounds like you want to increase the height of the progress view in iOS7, and the code you used previously in iOS6 is no longer working.

I had to solve a similar problem recently and I did this by adding a constraint to the progress view in Interface Builder and setting the height explicitly through the constraint. This solution will require the use of Auto-Layout, so be sure that you have that turned on.

Shown: the "Height" attribute on the Size Inspector is visibly greyed out for a Progress View and cannot be changed - however I've defined a constraint on the Progress View itself and set the constraint's height to 50 points, which is actually reflected in IB.

From what I've seen iOS6 Progress Bars have a static height value, so if you also want to support iOS6 then another approach will be necessary for that.




回答2:


Whereas others have reported that a CGAffineTransform() works as well:

[self.progressView setTransform:CGAffineTransformMakeScale(1.0, 3.0)];



回答3:


Use this Code :-

 CGAffineTransform transform = CGAffineTransformMakeScale(1.0f, 5.0f);
 progressView.transform = transform;



回答4:


Already answered here How to increase height of UIProgressView

@implementation UIProgressView (customView)

- (CGSize)sizeThatFits:(CGSize)size 
{
   CGSize newSize = CGSizeMake(self.frame.size.width,9);
   return newSize;
}

@end



回答5:


Here's the Swift version of user3189408 and Rushabh's great solutions for newer developers and swift enthusiasts like me. Tested for iOS 7+/Swift 2.0.

    progressView.transform = CGAffineTransformMakeScale(1.0, 5.0)



回答6:


Swift 3.x

progressView.transform = CGAffineTransform(scaleX: 1.0, y: 5.0)



回答7:


You can note that frame cannot be set by appearance accessor. You have to set it on each progress view separately.

Usually, the height is set depending on progress bar style.

- (id)initWithProgressViewStyle:(UIProgressViewStyle)style; // sets the view height according to the style


来源:https://stackoverflow.com/questions/18717895/progress-view-height-in-ios-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!