둥근 모서리가 아닌 사각형을 사용하려고하는 UIProgressView가 있습니다. 이렇게하려면 분명한 방법이 없기 때문에 진행 이미지 자체를 사각 프레임보다 약간 크게하여 진행 이미지가 사각형 모양으로 잘 리도록하는 것이 좋습니다. 그러나 진행률 이미지의 크기를 어떻게 변경하든이 효과를 얻을 수는 없습니다. 내가하려는 일을 성취 할 수있는 방법이 있는지 누군가가 말해 줄 수 있습니까? 여기 둥근 모서리 효과보다 정사각형 만들기 UIProgressView
내가 현재 UIView 하위 내부에있는 것입니다 :self.progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];
self.progressView.trackImage = [PLStyle imageForColor:[PLColors greyLight] inFrame:CGRectMake(0, 0, 1, ProgressViewHeight)];
self.progressView.progressImage = [PLStyle imageForColor:[PLColors orange] inFrame:CGRectMake(0, 0, 1, ProgressViewHeight)];
[self.progressView setTranslatesAutoresizingMaskIntoConstraints:NO];
[self addSubview:self.progressView];
[self addConstraint:
[NSLayoutConstraint constraintWithItem:self.progressView
attribute:NSLayoutAttributeLeading
relatedBy:NSLayoutRelationEqual
toItem:self.imageView
attribute:NSLayoutAttributeTrailing
multiplier:1
constant:LeadingOrTrailingSpace]];
[self addConstraint:
[NSLayoutConstraint constraintWithItem:self.progressView
attribute:NSLayoutAttributeCenterY
relatedBy:NSLayoutRelationEqual
toItem:self
attribute:NSLayoutAttributeCenterY
multiplier:1
constant:0]];
[self addConstraint:
[NSLayoutConstraint constraintWithItem:self.progressView
attribute:NSLayoutAttributeTrailing
relatedBy:NSLayoutRelationEqual
toItem:self.counter
attribute:NSLayoutAttributeLeading
multiplier:1
constant:-LeadingOrTrailingSpace]];
[self addConstraint:
[NSLayoutConstraint constraintWithItem:self.progressView
attribute:NSLayoutAttributeHeight
relatedBy:NSLayoutRelationEqual
toItem:nil
attribute:NSLayoutAttributeNotAnAttribute
multiplier:1
constant:ProgressViewHeight]];
// 당신은 항상 자신의 롤 수
+ (UIImage *)imageForColor:(UIColor *)color inFrame:(CGRect)rect
{
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}