UIProgressView custom images doesn't work in iOS 7.1

别等时光非礼了梦想. 提交于 2019-12-13 07:06:31

问题


I have an app using progress views with custom images. I use the code below:

[cell.proStatus setTrackImage: [[UIImage imageNamed:@"CircleGrey.png"] resizableImageWithCapInsets:UIEdgeInsetsZero]];
[cell.proStatus setProgressImage: [[UIImage imageNamed:@"CirclePurple.png"] resizableImageWithCapInsets:UIEdgeInsetsZero]];

It all works fine in iOS 6 and 7.0 - BUT when updating to iOS 7.1 it doesn't show the images - just the small little thin line (the standard progress view). What do I do?

I have searched and read here in stack overflow of course. And i have found the following:

UIProgressView custom track and progress images in iOS 7.1

But I can't get it to work? I'm a little new to this programming. Can someone please tell me (simple and basics) what i have to do to get it to work? In the thread I linked to the answer is to implement a JEProgressView from github. Maybe I'm just too much a beginner to completely understand how to do that. I have googled and tried, but it just won't work.


回答1:


Okay I have worked it out. I know it must be very basic Xcode stuff - but if there is others who have the same issue as I had, here is what I did.

  • Download the JEProgressView files from github. (https://gist.github.com/JohnEstropia/9482567)
  • Import them into the project.
  • In the storyboard (if you use that) select the current ProgressView, and in the right side of the screen under 'Identity inspector', in the field 'Class' enter : "JEProgressView"

Maybe it is placed a little different on the screen, and you have to adjust a little afterwards in the x and y frame settings. But after these steps it should work!

Pretty simple, but for a beginner like me it took some time to figure out :-P Hopefully this can save some time for other beginners ;-)




回答2:


Try this for iOS version 7.1 and above in customizing progress image:

if ([[UIDevice currentDevice] systemVersion] >= 7)
{
    [cell.proStatus setTrackTintColor: [UIColor colorWithPatternImage: [[UIImage imageNamed:@"CircleGrey.png"]     resizableImageWithCapInsets:UIEdgeInsetsZero]]];
    [cell.proStatus setProgressTintColor: [UIColor colorWithPatternImage: [[UIImage imageNamed:@"CirclePurple.png"] resizableImageWithCapInsets:UIEdgeInsetsZero]]];
}


来源:https://stackoverflow.com/questions/22540200/uiprogressview-custom-images-doesnt-work-in-ios-7-1

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