【ios开发】代码实现与注释

这篇博客介绍了iOS开发中的视图控制器和主图插入的方法。通过示例代码展示了如何创建ViewController,设置主图的尺寸和位置,并在视图中添加UIImageView。此外,还提及了对标题的设定以及编写tab栏的相关内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

视图控制模块:
import UIKit

class ViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.}

}

主图插入与位置实现:
import UIKit
let appw = UIScreen.main.bounds.size.width
let apph = UIScreen.main.bounds.size.height
class jibenxinxiViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()

self.title=“基本信息”
// Do any additional setup after loading the view.
let img = UIImageView()
img.frame = CGRect.init(x: 50, y: 64, width: appw-100, height: appw-100)
img.image = UIImage.init(named: “1.jpg”)
self.view.addSubview(img)

    let img2 = UIImageView()
    img2.frame = CGRect.init(x: 50, y: 79+(appw-100)+15, width: appw-100, height: appw-100)
    img2.image = UIImage.init(named: "2.jpg")
    self.view.addSubview(img2)
}


/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    // Get the new view controller using segue.destination.
    // Pass the selected object to the new view controller.
}
*/

编写tab栏:

    <scene sceneID="K8v-p0-0Hy">
    <objects>
    <tabBarController id="SmL-Fv-o8e" sceneMemberID="viewController">
    <tabBar key="tabBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="CRM-WH-Q02">
     <rect key="frame" x="0.0" y="0.0" width="375" height="49"/>
     <autoresizingMask key="autoresizingMask"/>
     <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
     </tabBar>
     <connections>
     <segue destination="S3a-c9-zvn" kind="relationship" relationship="viewControllers" id="tHM-bk-Axk"/>
   <segue destination="kdA-xd-JX6" kind="relationship" relationship="viewControllers" id="aeh-IN-PUc"/>
   <segue destination="Cqw-QF-NTY" kind="relationship" relationship="viewControllers" id="CuR-Dt-GUL"/>
   <segue destination="2Bw-gb-WZ1" kind="relationship" relationship="viewControllers" id="ufN-mL-VXI"/>
   <segue destination="gaP-AP-D1C" kind="relationship" relationship="viewControllers" id="rxx-uC-KWG"/>
   </connections>
   </tabBarController>
   <placeholder placeholderIdentifier="IBFirstResponder" id="a6B-8c-a38" userLabel="First Responder" sceneMemberID="firstResponder"/>
        </objects>
        <point key="canvasLocation" x="-2313" y="-202"/>
    </scene>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值