Swift:我的第一个Demo(UILabel和UIButton)

这篇博客介绍了如何在Swift中使用UILabel和UIButton实现交互效果,当按钮被按下时,UILabel的文字会从'hello'变为'感谢点击',松手后恢复原样。涉及到的文件包括AppDelegate.swift和ViewController.swift。
摘要由CSDN通过智能技术生成

完成的逻辑,按下按钮从hello变成感谢点击,松手还原

文件名:AppDelegate.swift

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        window = UIWindow(frame: UIScreen.main.bounds)
        let rootview = ViewController()
        window?.rootViewController = rootview
        window?.makeKeyAndVisible()
        return true
    }

    func applicationWillResignActive(_ application: UIApplication) {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of tempor
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值