Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
274 views
in Technique[技术] by (71.8m points)

uiimageview - How do I load an image into a complication programmatically iOS

I have a app which has an Apple Watch extension. I have a UIImageView in the Watch face and would like to have the image change depending on condition. I have tried this.

if ((battery > 30)&& (battery < 110) && (bat = 1)){
           UIImage *lightning = [UIImage imageNamed:@"[email protected]"];
           [self.Jag setImage:lightning];
       }

I have put the jag@@2x.png in my watch asserts folder but when I call this it doesn't load no image appears. If I load it in IB it is ok any ideas?

question from:https://stackoverflow.com/questions/66056286/how-do-i-load-an-image-into-a-complication-programmatically-ios

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

So I got this working. I added the images to the assets.xcassett in the watch extension and then left off the @2x as Paulw11 suggested but I did need to leave the .png on to get it to work. Thanks Paul for pointing me in the correct direction.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...