.xib是个xml文件,能用xcode以源码形式打开

   有时候纯代码写界面有时候会降低开发效率,对于一些通用简单的界面,例如程序设置界面,可以使用xib进行开发。
关于xib

1. xib和nib

xib文件可以被Xcode编译成nib文件,xib文件本质上是一个xml文件,而nib文件就是编译后的二进制文件,该文件将视图等控件对象封装了起来,而在程序运行起来后,这些对象会被激活。

xib文件本质上是一个xml文件,可以用vim或cat命令查看如下:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10116" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
    <dependencies>
        <deployment identifier="iOS"/>
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
    </dependencies>
    <objects>
        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="BSRecommendController">
            <connections>
                <outlet property="categoryTableView" destination="D79-ql-6zX" id="F4p-bh-dYd"/>
                <outlet property="userTableView" destination="3pk-tV-6rF" id="Feo-vZ-b6X"/>
                <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
            </connections>
        </placeholder>
        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
        <view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
            <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
            <subviews>
                <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="none" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="D79-ql-6zX" userLabel="左侧view">
                    <rect key="frame" x="0.0" y="0.0" width="90" height="600"/>
                    <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
                    <constraints>
                        <constraint firstAttribute="width" constant="90" id="tzr-jz-TrE"/>
                    </constraints>
                    <connections>
                        <outlet property="dataSource" destination="-1" id="u3N-uS-NL8"/>
                        <outlet property="delegate" destination="-1" id="uuX-lR-3OZ"/>
                    </connections>
                </tableView>
                <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="none" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="3pk-tV-6rF" userLabel="右侧view">
                    <rect key="frame" x="90" y="0.0" width="510" height="600"/>
                    <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                    <connections>
                        <outlet property="dataSource" destination="-1" id="Axi-GV-K1x"/>
                    </connections>
                </tableView>
            </subviews>
            <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
            <constraints>
                <constraint firstItem="D79-ql-6zX" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="LrH-tR-cZm"/>
                <constraint firstAttribute="bottom" secondItem="D79-ql-6zX" secondAttribute="bottom" id="UMV-LH-8yh"/>
                <constraint firstItem="D79-ql-6zX" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" id="ZWp-ZL-Zda"/>
                <constraint firstItem="3pk-tV-6rF" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" id="bWi-bF-GVt"/>
                <constraint firstAttribute="trailing" secondItem="3pk-tV-6rF" secondAttribute="trailing" id="eYg-nr-KTK"/>
                <constraint firstAttribute="bottom" secondItem="3pk-tV-6rF" secondAttribute="bottom" id="mdd-l9-MP4"/>
                <constraint firstItem="3pk-tV-6rF" firstAttribute="leading" secondItem="D79-ql-6zX" secondAttribute="trailing" id="nv5-go-Ye6"/>
            </constraints>
        </view>
    </objects>
</document>

nib文件在程序的Build目录下找到。

操作如下图:

效果图如下:

 

转载于:https://www.cnblogs.com/SuperInvincible/p/5720812.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值