Rendering SF Symbols with NativeScript using UIImageView - nativescript

I would like to use SF Symbols in a NativeScript based app (using svelte native but I guess this should work independent of that).
If I understand this guide to SF Symbols correctly then I can get a view with a symbol like this in Swift:
let image = UIImage(systemName: "star")
let imageView = UIImageView(image: image)
translating into NativeScript like this (see this question):
let image = UIImage.systemImageNamed("star")
let imageView = new UIImageView({ image: image })
Specifically, I would like to render this inside the actionBar, i.e. an actionItem.
What I am struggling with is how to get this into an own component or finding a NativeScript component that would render this view. Or am I on a complete wrong path?
Help is very much appreciated. I am just getting started with NativeScript and I am sorry if this seems like an obvious question.

Related

How can we merge multiple image into single image in react native project

In one of my project I am using RNCamera for capturing image. Also the camera screens have custom components. One of the component showing with camera is compass image. I need to merge the compass image with the captured image.
I have tried this library react-native-view-shot. Wrapping the RNCamera inside the view shot view. But the result contains only the captured image without compass.
I have also tried react-native-images-combine. Here the second image is always positioning at the left side of the first image.
I looking for a better solution. Can anyone suggest a way to fix this in react-native. It would be great. Thank you.
Try to put both images in a View tag and each image in an own View tag. Than give “z-index” style property to put your image above.
Let me know!

How can I anchor a Reality Composer (RealityKit) scene to a detected image

Anchor RealityKit Scene to Image Target
I have tried using the limited documentation to write the code but I haven't succeeded. I can only get a scene to anchor to a horizontal plane.
Can anyone suggest some simple code that would link a scene made in reality composer to an image target?
How would I= change/add to this code below?
let arConfiguration = ARWorldTrackingConfiguration()
arConfiguration.planeDetection = .horizontal
arView.session.run(arConfiguration)
guard let anchor = try? Spinner.loadScene() else { return }
arView.scene.anchors.append(anchor)
Did you setup an image anchor directly in RC? It's quite straight forward, I can explain if it helps.
I have found that the model drifts slightly when using an image anchor, I hope this gets fixed soon.

Xamarin iOS Slider color

I have a slider in a Xamarin Forms app that I'm trying to change the color of the thumb and the slider bar. In Android it was easy to override this in a renderer, but in iOS it looks like all I can do is change the thumb image. Is it possible to change the bar color? Thanks!
You can use the TintColor:
var slider = new UISlider(View.Frame);
slider.ThumbTintColor = UIColor.Blue;
slider.MinimumTrackTintColor = UIColor.Red;
slider.MaximumTrackTintColor = UIColor.Green;
I also just found a new plugin that does all of that and a lot more. It will probably be overkill for just that but if you plan to do a lot more custom stuff to controls it might be helpful.
I have not tried it myself but I looking forward to using it soon.
XF Gloss

How to use UIVisualEffectView with Objective-C

I've been looking for documentation on how to use the UIVisualEffectView with Objective-C in iOS8.
I've seen some code examples but would appreciate the steps to use the actual view in the Object Library. This is what I tried, which had no effect:
Create a new storyboard scene
Add a UIVisualEffectView
Add a UIImageView
Add a picture to the UIImageView
I want to have a blurred picture as the background for my scenes. Can someone point me to a tutorial or provide instructions?
Thanks
I have implemented a demo which demonstrates using UIVisualEffectView with vibrancy and also with vibrancy & blur. It uses a little bit different way of implementing via storyboard so look at https://github.com/Vaberer/BlurTransition.

SpriteKit unarchiveFromFile does not load textures from asset catalogues and atlases

I'm still new with SpriteKit, and wanted to see if I can construct a level using Xcode's SKS editor. When i added a couple of sprites with the "Spaceship.png" texture and built the template app, the textures don't load.
Here's a screenshot of the vanilla OSX Game template using Swift as the language, and adding a supplied "Spaceship.png" sprite. The texture shows fine:
And here's the result of building and running the app with only that modification to the template:
The debug console displays this warning message:
I tried to add an .atlas folder, and got the same result. the scene just displays the red X icon in place of the sprite. If the added sprites where just color sprites, they display fine. I had an app some time ago that I scrapped, where I used to load the SKScene and would manually add the sprite assets within to my SKScene sub-class, and it worked fine.
If, however, i moved the textures - "Spaceship.png" as an example - to the root of the project, i.e. not inside an asset catalogue or .atlas folder, the scene loads with the textures displaying fine.
Here's the texture added to the root of the project:
And this is the desired result:
I tried to manually add the loaded assets from the SKS file to the scene via enumerateChildNodesWithName(_,usingBlock) and I get the same result if the textures were not in the root of the project folder.
This is me trying to add the assets manually:
func applicationDidFinishLaunching(aNotification: NSNotification) {
/* Pick a size for the scene */
if let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene {
let sceneToBePresented = GameScene()
/* Set the scale mode to scale to fit the window */
sceneToBePresented.scaleMode = .AspectFill
sceneToBePresented.size = scene.size
/* Sprite Kit applies additional optimizations to improve rendering performance */
self.skView!.ignoresSiblingOrder = true
self.skView!.showsFPS = true
self.skView!.showsNodeCount = true
scene.enumerateChildNodesWithName("*") { node, stop in
sceneToBePresented.addChild(node.copy() as SKSpriteNode)
}
self.skView!.presentScene(sceneToBePresented)
}
}
I looked around SpriteKit classes - SKNode, SKScene, SKTexture, SKSPriteNode - for any clue about paths, caching, preloading, or anything but was unable to find a thing that could make this work.
I am running Xcode 6.1.1 and my target is 10.9, and the language I'm using is Swift, although the same behavior holds true using ObjC. Is this a feature or a bug? Anybody else running/ran into a similar situation ?
Thanks in advance for any help
[UPDATE]
Looks like this is not implemented yet - loading textures from asset catalogs - as this post in the dev forums discusses the same issue, and his solution is to rename the asset catalogues to be the same name as the texture. In essence, what I found out about having the image files in the root folder: How do you load sprite textures from Images.xcassets when using SKS scene file, although my earlier app which i managed to roll-back to a working state does load textures from .atlas'es, but i can't seem to do it with a clean template!!!
[Answering my own question here]
As far as I can tell, at this moment, loading texture from asset catalogues - Images.xcassets - while unarchiving or deserializing an SKScene file does not work on OSX based on my attempts and the devforumns post referenced above.
Loading of the textures from image atlases, however, works by forcing SKTexture to load the image. Forcing or 'touch'ing SKTexture can be done via the preloadWithCompletionHandler(_:) or preloadTextures(_:, withCompletionHandler:) methods, or simply by printing the description of the sprite's SKTexture as i have discovered.
For the benefit of anybody who might need further assistance, here is a code snippet that preloads the textures after unarchiving an SKS file:
if let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene {
for child in scene.children as [SKNode] {
if child is SKSpriteNode {
let sprite = child as SKSpriteNode
sprite.texture?.preloadWithCompletionHandler({ })
/* or even a simple debug log of the texture */
/* println(sprite.texture) */
}
}
/* Do your other stuff ... */
...
}
If I'm wrong please correct me. Until somebody does, or Apple fixes the discrepancy between SpriteKit's behavior between iOS and OSX, I will not be looking for another solution, and will follow Murphey's law:
If it works, don't fix it
Follow Salam Horani solution's, for Swift 2.x you dont have yet "unarchiveFromFile" so you can create scene like this:
if let gameScene = GameScene(fileNamed: "GameScene") {
// ...
}

Resources