asset-catalog

Images inaccessible from asset catalog in a SwiftUI framework

耗尽温柔 提交于 2020-12-07 04:55:22
问题 I've created an iOS framework that contains a single SwiftUI View . I've then added an Asset Catalog with a single image. Trying to access that image from the SwiftUI view doesn't do anything - I see a blank image. Image("MyImage") The Xcode Preview doesn't show anything, nor does the view show anything for a test target I wrote that uses the framework. So the question is - how do I bundle images with a framework that uses SwiftUI? Is this not supported? The only way I could get this to work

Images inaccessible from asset catalog in a SwiftUI framework

天涯浪子 提交于 2020-12-07 04:54:36
问题 I've created an iOS framework that contains a single SwiftUI View . I've then added an Asset Catalog with a single image. Trying to access that image from the SwiftUI view doesn't do anything - I see a blank image. Image("MyImage") The Xcode Preview doesn't show anything, nor does the view show anything for a test target I wrote that uses the framework. So the question is - how do I bundle images with a framework that uses SwiftUI? Is this not supported? The only way I could get this to work

How to add GIF images to Asset Catalog in XCode5

狂风中的少年 提交于 2020-01-11 08:29:07
问题 Does any one know how to add GIF image files to an Asset Catalog in XCode5? 回答1: Go to your Images.xcassets folder and create a folder named MyGifAnimation.xcassets, then put your MyGifAnimation@2x.gif and MyGifAnimation.gif files in it. After that, create a Contents.json file. Open that with your favorite text editor and write the following in it: { "images": [{ "idiom": "universal", "scale": "1x", "filename": "MyGifAnimation.gif" }, { "idiom": "universal", "scale": "2x", "filename":

Opt into app thinning for icons in asset catalog in existing project

≡放荡痞女 提交于 2020-01-01 09:43:51
问题 At WWDC 2017 Session 201 What's New in Cocoa Touch, around the 33:50 mark, it is stated that "By incorporating [icons] in Asset Catalogs, we're now able to have them participate in the app thinning, which will significantly lower your app's footprint. So, this is a really exciting thing to adopt, and it will be adopted by default in new projects in iOS 11. You can opt into it in existing projects by adding a key to your Info.plist." What is the key you need to add in your Info.plist to enable

Creating CPTImages from images in xcassets file

↘锁芯ラ 提交于 2019-12-25 11:04:13
问题 So according to this, you have to use imageNamed for loading images now in iOS. Unfortunately, CPTImage's constructors requires paths for loading images So something like this: [CPTImage imageForPNGFile:[[NSBundle mainBundle] pathForResource:@"plotsymbol" ofType:@"png"]] These -pathForResource calls now fail because of asset catalogs. So.. has anyone been able to do this? Did I miss something? 回答1: The CPTImage class will include an imageNamed method in a future release. It is available now

No Retina 4 option in xcode 7 then how do I set fullscreen images in asset to make them show correctly in 4s/5s & iPhone 6?

放肆的年华 提交于 2019-12-24 12:26:07
问题 In xcode 7 these is no retina 4 option, according to this, apple removed it on purpose. I did edit Contents.json to get it back but the effect is not the same! I remember in XCode6/pre-iOS9 iPhone 6 will used retina 4 picture so I only need to set one fullscreen 2x picture for iPhone 4/4s, one fullscreen Retina 4 for iPhone 5/5s and 6. I think using Retina4 for iPhone 6 really makes sense while 2x doesn't! Because 1334/750 is about 1.778, which is close to 1136/640 = 1.775 while 960/640 = 1.5

Landscape vs. Portrait background image in Asset Catalog

和自甴很熟 提交于 2019-12-24 12:15:00
问题 I have a use case that seems to fall into the cracks between asset catalogs and size classes. My Universal app needs a full screen background image that is different in Landscape and Portrait orientations, and Landscape is only supported for the iPad & iPhone 6. Since I can't add landscape images to the asset catalog for a new image set, my current solution looks like this (supports iOS 7 & 8): // permit landscape mode only for iPads & iPhone 6 (would prefer to use size classes, but...?)

Create SKSpriteNode with an Asset Programmatically

ぃ、小莉子 提交于 2019-12-22 13:53:50
问题 I'm attempting to programmatically create an SKSpriteNode and give it a texture that is in my Assets.xcassets folder. I figured this would be a basic procedure, but I seem to be having a lot of troubles. For a reference, here is my asset catalog with the ground asset I'm trying to set to a SKSpriteNode : Here's the code to make the sprite node: sprite.texture = SKTexture(image: UIImage(named: spriteName)!) sprite.anchorPoint = CGPoint(x: 0, y: 1) sprite.position = CGPoint(x: 0, y: 0)

Getting video from Asset Catalog using On Demand ressources

和自甴很熟 提交于 2019-12-22 08:57:06
问题 I attributed to my .mp4 video the "tokyo" tag for example, and set it as installed during the app installation. Now before I was using a Path to get it from my resources, now it's different because it's located on the Asset Catalog. After found documentations, I tried something like : NSBundleResourceRequest(tags: ["tokyo"]).beginAccessingResourcesWithCompletionHandler { (error) -> Void in let tokyoVideo = NSDataAsset(name: "tokyo") So I can do : tokyoVideo.data to access NSData but I'm using

How do I load an image from the Asset Catalog on cross-platform xamarin XAML?

我们两清 提交于 2019-12-22 08:52:02
问题 It seems like a really easy thing to do, and in theory it looks very straight forward: create the Asset Catalog add an Image Set and name it "imageName" (without .png) add the images done or at least that's what i read pretty much everywhere, but I still can't get it to work. My XAML looks like this: <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:CrossBaiscs" x