I'm developing an iOS app with latest SDK.
I have this resource from an Android app that I did:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gauge_background">
<gradient
android:startColor="#449def"
android:endColor="#2f6699"
android:angle="270" />
<stroke
android:width="1dp"
android:color="#2f6699" />
<corners android:radius="30dp" />
<padding
android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp" />
</shape>
And would like to use it in my iOS app.
Do you know if there is a way to load this xml and show it as an UIView backgroundColor?
Something like this:
self.backgroundColor =
[[UIColor alloc] initWithPatternImage:[UIImage imageNamed:imageName]];
There's no way to do this without converting the original android shape definition to something you can display in a UIView (ie. a nib, or core graphics drawing instructions.)
As far as I am aware no such conversion tool exists.
I'd suggest you look at a tool like paintcodeapp to ease the creation of dynamic graphics for your iOS project. (it'll import SVG and turn them into drawing code)
It's very useful for example if you need to anchor / stretch a shape without distorting key parts.
Yep, there is no way as @Slomojo said.
If u can, You may convert the xml data in to an UIImage and then load that image as UIcoloras u mentioned
self.backgroundColor =[[UIColor alloc] initWithPatternImage:[UIImage imageNamed:imageName]];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With