如何将Android xml布局转换为png / svg以在iOS版本中使用

我这里有一个Android布局xml文件:

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/locationMarker"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginBottom="30dp"
        android:gravity="center"
        android:orientation="vertical">

        <TextView
            android:id="@+id/locationMarkertext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/rounded_corner_map"
            android:gravity="center"
            android:minWidth="180dp"
            android:onClick="create"
            android:paddingLeft="2dp"
            android:paddingRight="2dp"
            android:text="Pick the Location"
            android:textColor="@android:color/white" />

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@android:color/transparent"
            android:onClick="create"
            android:src="@drawable/plus" />
    </LinearLayout>

此xml布局呈现如下所示:

Pin layout xml screenshot

这适用于Android,但我想在iOS应用程序上使用此xml布局.我想知道是否有办法将此xml布局转换为svg或png格式或任何允许我重新使用此项而无需重新创建它的方法.它需要具有透明度,如果可行的话,.svg很可能比.png更好.如果可能的话,我希望只显示可见部分.

解决方法:

iOS中的等效技术是Apple的“自动布局”系统.

一旦掌握了它,它就很容易使用;事实是,就像任何事情一样,这是一个专业的事情.当然,你可以制作一个透明的PNG并将其用作UIButton的图像.

我真的建议在Apple中使用“UIButton”,并使用颜色等,直到你看起来没问题 – 尽管与其他平台不同.

两个关键点是

>从技术上讲,在不同平台上使应用看起来几乎是不可能的
>几乎每个人都同意你不应该试图这样做;除了在游戏中,允许按钮等元素在每个平台/ os版本上都是“自然的”.

顺便说一下,我不知道为什么有人会对你的问题进行投票.跨平台问题是当今发展中最关键的问题之一.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...