UIKit学习笔记—第一节View and Window Architecture

大师学SwiftUI第16章 - UIKit框架集成 其它相关内容请见​​是一套新框架,因此并没有包含我们构建专业应用所需的所有工具。这意味着我们会需要求助于(移动设备)和(Mac电脑)等原生框架所提供的工具。我们已介绍过。它是一套在后台实现用于创建大部分视图和控件的框架。有些类用于运行应用(​​​)、加载图片(​​UIImage​​​)、管理设备(​​UIDevice​​​)及窗口(​​UIWindow​​​),而另一些定义用于设置应用和场景(​​​和​​​)的代理。当然,该框架提供了我们创建界面所需的所有工具,包括两个创建和管理视图的基本类,称为​。 阅读详情

各位iOS开发大佬们好:
我是一名Swift+SwiftUI栈的iOS小白,目前还在上大三,最近准备实习,面试的过程中发现现在大公司很多还在用OC + UIKit的技术栈,OC我还在考虑要不要学,目前想先把UIKit学完,这是我在官网学习UIKit英文文档时摘录的本人认为的重点,如果你们也觉得对你们有用的话欢迎持续关注,我大概一天更一节,有事除外。格式什么的我也就不做了,翻译都是我自己翻译的,哪里不对欢迎在评论区指正,感谢各位大佬支持

今天2021年11月27日
这一章叫做View and Window Architecture

Each superview stores its subviews in an ordered array and the order in that array also affects the visibility of each subview. If two sibling subviews overlap each other, the one that was added last (or was moved to the end of the subview array) appears on top of the other.

每个视图都将他的子视图储存在一个有序数组当中,顺序影响着子视图的展示,如果两个子视图互相覆盖,那么栈顶视图将会覆盖其他视图

When a view first appears on the screen, the system asks it to draw its content. The system captures a snapshot of this content and uses that snapshot as the view’s visual representation. If you never change the view’s content, the view’s drawing code may never be called again. The snapshot image is reused for most operations involving the view. If you do change the content, you notify the system that the view has changed. The view then repeats the process of drawing the view and capturing a snapshot of the new results.

当一个视图第一次出现在屏幕上时,系统要求它渲染自己的内容,系统获取一张内容的快照呈现视觉内容,如果你不更改视图内容,那么渲染代码不会再被调用,快照用于涉及视图的大部分操作,如果你确实更改了视图内容,视图会重复上述操作获得新的内容快照

When the contents of your view change, you do not redraw those changes directly. Instead, you invalidate the view using either the setNeedsDisplay or setNeedsDisplayInRect: method. These methods tell the system that the contents of the view changed and need to be redrawn at the next opportunity. The system waits until the end of the current run loop before initiating any drawing operations. This delay gives you a chance to invalidate multiple views, add or remove views from your hierarchy, hide views, resize views, and reposition views all at once. All of the changes you make are then reflected at the same time.

当视图内容更改时,你实际上不是重新渲染这部分内容,相反的,你首先使用setNeedsDisplay 或 setNeedsDisplayInRect: 使视图无效,这些方法通知系统将在下一帧时重新渲染这些更改,系统等待当前runloop结束之后初始化其他渲染操作,这段时间使你能够使更多的视图无效,从你的视图树中添加或移除视图,隐藏,定位,或重设视图大小,所有你做的更改均会被即时反映出来
Content modes are good for recycling the contents of your view, but you can also set the content mode to the UIViewContentModeRedraw value when you specifically want your custom views to redraw themselves during scaling and resizing operations. Setting your view’s content mode to this value forces the system to call your view’s drawRect: method in response to geometry changes. In general, you should avoid using this value whenever possible, and you should certainly not use it with the standard system views.

内容的显示模式有利于视图的重复利用,当你想要让你的自定义视图在初始化期间重新渲染,可以在 UIViewContentModeRedraw 属性中使用这些模式,这会强制系统调用视图的drawRect: 方法来响应形状的更改,你不应该使用它,更不可以和系统视图一起使用。

You can designate a portion of a view as stretchable so that when the size of the view changes only the content in the stretchable portion is affected. You typically use stretchable areas for buttons or other views where part of the view defines a repeatable pattern. The stretchable area you specify can allow for stretching along one or both axes of the view. Of course, when stretching a view along two axes, the edges of the view must also define a repeatable pattern to avoid any distortion. Figure 1-3 shows how this distortion manifests itself in a view. The color from each of the view’s original pixels is replicated to fill the corresponding area in the larger view

您可以将视图的一部分指定为可伸缩部分,以便在视图大小更改时,仅影响可伸缩部分的内容。您通常将可伸缩区域用于按钮或其他视图,其中视图的一部分定义了可重复模式。您指定的可伸缩区域可以沿着视图的一个或两个轴伸展。当然,当沿着两个轴拉伸视图时,视图的边缘还必须定义可重复的模式,以避免任何失真。图1-3显示了这种失真如何在视图中表现出来。复制视图每个原始像素的颜色,以填充大视图中的相应区域。

Built—in Animation Support
frame—Use this to animate position and size changes for the view.
bounds—Use this to animate changes to the size of the view.
center—Use this to animate the position of the view.
transform—Use this to rotate or scale the view.
alpha—Use this to change the transparency of the view.
backgroundColor—Use this to change the background color of the view.
contentStretch—Use this to change how the view’s contents stretch.

frame is from the outside of the view
Bounds is from the inside of the view

When you set the frame property, the size value in the bounds property changes to match the new size of the frame rectangle. The value in the center property similarly changes to match the new center point of the frame rectangle.
When you set the center property, the origin value in the frame changes accordingly.
When you set the size of the bounds property, the size value in the frame property changes to match the new size of the bounds rectangle.

frame center bounds的联系
frame改变bounds的大小
Bounds改变frame的大小但不改变位置
center改变frame位置但不改变大小

在这里插入图片描述

坐标系统从左上到右下,浮点数

Core Graphics and OpenGL ES use a coordinate system whose origin lies in the lower-left corner of the view or window and whose y-axis points upward relative to the screen

OpenGL ES的坐标系统从左下到右上

The user touches the screen.
The hardware reports the touch event to the UIKit framework.
The UIKit framework packages the touch into a UIEvent object and dispatches it to the appropriate view. (For a detailed explanation of how UIKit delivers events to your views, see Event Handling Guide for iOS.)
The event-handling code of your view responds to the event. For example, your code might:
Change the properties (frame, bounds, alpha, and so on) of the view or its subviews.
Call the setNeedsLayout method to mark the view (or its subviews) as needing a layout update.
Call the setNeedsDisplay or setNeedsDisplayInRect: method to mark the view (or its subviews) as needing to be redrawn.
Notify a controller about changes to some piece of data.
Of course, it is up to you to decide which of these things the view should do and which methods it should call.
If the geometry of a view changed for any reason, UIKit updates its subviews according to the following rules:
If you have configured autoresizing rules for your views, UIKit adjusts each view according to those rules. For more information about how autoresizing rules work, see Handling Layout Changes Automatically Using Autoresizing Rules.
If the view implements the layoutSubviews method, UIKit calls it.You can override this method in your custom views and use it to adjust the position and size of any subviews. For example, a view that provides a large scrollable area would need to use several subviews as “tiles” rather than create one large view, which is not likely to fit in memory anyway. In its implementation of this method, the view would hide any subviews that are now offscreen or reposition them and use them to draw newly exposed content. As part of this process, the view’s layout code can also invalidate any views that need to be redrawn.
If any part of any view was marked as needing to be redrawn, UIKit asks the view to redraw itself.For custom views that explicitly define a drawRect: method, UIKit calls that method. Your implementation of this method should redraw the specified area of the view as quickly as possible and nothing else. Do not make additional layout changes at this point and do not make other changes to your application’s data model. The purpose of this method is to update the visual content of your view.
Standard system views typically do not implement a drawRect: method but instead manage their drawing at this time.
Any updated views are composited with the rest of the application’s visible content and sent to the graphics hardware for display.
The graphics hardware transfers the rendered content to the screen.

  1. 用户触屏
  2. 硬件检测后通知UIKit
  3. UIKit打包为一个UIEvent对象之后传给可能的响应视图
  4. A 更改一些动画属性的值
    B 调用setNeedsLayout 方法标记视图需要更改布局
    C 调用setNeedsDisplay 或 setNeedsDisplayInRect:方法标记视图需要被重新渲染
    D 通知controller可能需要更改的一些数据
  5. (4)中操作有你决定是否发生
  6. UIKit根据以下规则更改可能由于视图形状更改引起的子视图变化
    A 可以设置自动更改尺寸
    B 如果视图实现了layoutSubviews 方法,将会被调用,你可以重写此方法,此方法用于子视图尺寸位置适应父视图的变化
  7. drawRect:方法仅用于更新视觉内容,切勿做例如布局更改,数据模型更改等其他操作
  8. 所有更新后的视图都将被一起送往硬件部分渲染呈现
  9. 硬件部分渲染呈现

仿射变换

An affine transform is a mathematical matrix that specifies how points in one coordinate system map to points in a different coordinate system.
To modify your entire view, modify the affine transform in the transform property of your view.
To modify specific pieces of content in your view’s drawRect: method, modify the affine transform associated with the active graphics context.
You typically modify the transform property of a view when you want to implement animations.
The coordinate system of each subview builds upon the coordinate systems of its ancestors.
仿射变换是一个矩阵明确了将一个坐标系统上的点映射到另一个坐标系统的方法
如果修改整个视图的仿射坐标,使用transform 属性
如果修改视图的特定内容,使用drawRect: 属性
transform属性为可动画属性
So when you modify a view’s transform property, that change affects the view and all of its subviews.
However, these changes affect only the final rendering of the views on the screen
子视图的坐标系统建立在其父视图之上(即父视图左上为(0,0))
父视图的仿射变换会影响到其所有子视图
变换仅影响最终屏幕上的渲染

Tips for Using Views Effectively
Custom views are useful for situations where you need to draw something the standard system views do not provide, but it is your responsibility to ensure that the performance of your views is good enough. UIKit does everything it can to optimize view-related behaviors and help you achieve good performance in your custom views. However, you can help UIKit in this aspect by considering the following tips.
Important: Before optimizing your drawing code, you should always gather data about your view’s current performance. Measuring the current performance lets you confirm whether there actually is a problem and, if there is, gives you a baseline measurement against which you can compare future optimizations.

Views Do Not Always Have a Corresponding View Controller
There is rarely a one-to-one relationship between individual views and view controllers in your application. The job of a view controller is to manage a view hierarchy, which often consists of more than one view used to implement some self-contained feature. For iPhone applications, each view hierarchy typically fills the entire screen, although for iPad applications a view hierarchy may fill only part of the screen.
As you design your application’s user interface, it is important to consider the role that view controllers will play. View controllers provide a lot of important behaviors, such as coordinating the presentation of views on the screen, coordinating the removal of those views from the screen, releasing memory in response to low-memory warnings, and rotating views in response to interface orientation changes. Circumventing these behaviors could cause your application to behave incorrectly or in unexpected ways.
For more information view controllers and their role in applications, see View Controller Programming Guide for iOS.
Minimize Custom Drawing
Although custom drawing is necessary at times, it is also something you should avoid whenever possible. The only time you should truly do any custom drawing is when the existing system view classes do not provide the appearance or capabilities that you need. Any time your content can be assembled with a combination of existing views, your best bet is to combine those view objects into a custom view hierarchy.
Take Advantage of Content Modes
Content modes minimize the amount of time spent redrawing your views. By default, views use the UIViewContentModeScaleToFill content mode, which scales the view’s existing contents to fit the view’s frame rectangle. You can change this mode as needed to adjust your content differently, but you should avoid using the UIViewContentModeRedraw content mode if you can. Regardless of which content mode is in effect, you can always force your view to redraw its contents by calling setNeedsDisplay or setNeedsDisplayInRect:.
Declare Views as Opaque Whenever Possible
UIKit uses the opaque property of each view to determine whether the view can optimize compositing operations. Setting the value of this property to YES for a custom view tells UIKit that it does not need to render any content behind your view. Less rendering can lead to increased performance for your drawing code and is generally encouraged. Of course, if you set the opaque property to YES, your view must fill its bounds rectangle completely with fully opaque content.
Adjust Your View’s Drawing Behavior When Scrolling
Scrolling can incur numerous view updates in a short amount of time. If your view’s drawing code is not tuned appropriately, scrolling performance for your view could be sluggish. Rather than trying to ensure that your view’s content is pristine at all times, consider changing your view’s behavior when a scrolling operation begins. For example, you can reduce the quality of your rendered content temporarily or change the content mode while a scroll is in progress. When scrolling stops, you can then return your view to its previous state and update the contents as needed.
Do Not Customize Controls by Embedding Subviews
Although it is technically possible to add subviews to the standard system controls—objects that inherit from UIControl—you should never customize them in this way. Controls that support customizations do so through explicit and well-documented interfaces in the control class itself. For example, the UIButton class contains methods for setting the title and background images for the button. Using the defined customization points means that your code will always work correctly. Circumventing these methods, by embedding a custom image view or label inside the button, might cause your application to behave incorrectly now or at some point in the future if the button’s implementation changes.

使用自定义视图的小贴士
1.当你自定义视图时,考虑好viewcontroller扮演的角色
2.尽量使自定义绘图最少,就算用多个视图可以合成一个你需要的图形时,都不要自定义
3.尽量让视图不透明以提高性能,如果你声明视图不透明,那么内容必须填满整个视图
4.滚动时可以暂时降低视图内容的显示效果以获得更好的滚动体验
5.禁止为继承自UIControl的对象添加子视图

Unity与iOS原生应用深度集成:架构、实战与性能优化全解析 在移动应用开发中,跨平台引擎与原生系统的集成是提升应用表现力和功能丰富性的关键技术。其核心原理在于通过桥接机制,实现不同运行时环境间的通信与资源共享。这项技术的价值在于能够充分发挥Unity强大的实时3D渲染能力与iOS原生系统在性能、交互及生态服务上的优势,实现优势互补。在工程实践中,这尤其适用于需要嵌入高质量3D可视化模块的电商、教育、营销等混合型应用场景。本文聚焦于Unity与iOS的嵌入式集成模式,深入剖析了以UnityFramework为核心的架构设计,并提供了从环境配置、双向通信到内存与渲染优化 阅读详情

相关推荐

XC7Z010-1CLG400C开发板ADC引脚配置全攻略(附完整引脚列表)

本文详细解析了XC7Z010-1CLG400C开发板的ADC引脚配置方法,涵盖XADC模块基础、CLG400封装的引脚布局、硬件设计规范及Vivado工程配置实战。特别提供了完整的引脚列表和性能优化技巧,帮助开发者高效实现模拟信号采集,适用于Zynq-7000系列开发。

weixin_29188043的博客 467

UIKit各类概述

UIKit各类概述 1.UIAcceleration: 被叫做加速事件的一个UIAcceleration类的实例是用来代表即时的三维加速数据。为了接收重力加速度,要注册一个应用应用程序作为一个共享UIAccelerater对象的委托对象(参考UIAcceleromete类)。 2.UIAccelerater: UIAccelerater类可以让你的寄存器接收到从板载硬件上得到的加速相关数据

Mars_cyw的专栏 4768

音乐频谱灯的硬件艺术:从STM32到SK9822LED的工程美学

本文探讨了基于STM32微控制器和SK9822 LED的音乐频谱灯硬件设计与实现。通过ADC采集音频信号,利用FFT算法进行频谱分析,并驱动LED阵列呈现动态视觉效果,展现了硬件工程与艺术美学的完美融合。

Pepper的专栏 218

UIKit学习笔记—第三节Views

各位iOS开发大佬们好: 我是一名swift+swiftUI栈的iOS小白,目前还在上大三,最近准备实习,面试的过程中发现现在大公司很多还在用OC + UIKit的技术栈,OC我还在考虑要不要学,目前想先把UIKit学完,这是我在官网学习UIKit英文文档时摘录的本人认为的重点,如果你们也觉得对你们有用的话欢迎持续关注,我大概一天更一节,有事除外。格式什么的我也就不做了,翻译都是我自己翻译的,哪里不对欢迎在评论区指正,感谢各位大佬支持 这一章叫做Views View的职责和功能有很多,比如布局、管理子视图,

Programmer_Roy的博客 677

新手DIY无人机,从电机到飞控,这份配件清单和避坑指南请收好

本文为无人机DIY新手提供从电机到飞控的完整配件清单和避坑指南。详细解析电机KV值选择、电调匹配、飞控系统调试等核心问题,帮助初学者避开常见雷区,顺利完成首飞。特别推荐FPV竞速机和航拍机的配件组合方案,并附赠实用调试命令和故障排查表。

weixin_27032989的博客 239

Qt实战:用QCustomPlot实现毫秒级时间轴数据动态刷新(附完整代码)

本文深入探讨了在Qt框架下,如何利用QCustomPlot库高效实现毫秒级时间轴数据的动态刷新与实时可视化。针对工业物联网等高频数据场景,文章提供了从原理剖析、核心代码实现到性能优化的完整实战指南,包括滑动窗口管理、双定时器策略及坐标轴精确配置,帮助开发者构建稳定、流畅的专业级监控界面。

qsc90123456的博客 759

UIKit学习笔记—第四节Animations

各位iOS开发大佬们好: 我是一名swift+swiftUI栈的iOS小白,目前还在上大三,最近准备实习,面试的过程中发现现在大公司很多还在用OC + UIKit的技术栈,OC我还在考虑要不要学,目前想先把UIKit学完,这是我在官网学习UIKit英文文档时摘录的本人认为的重点,如果你们也觉得对你们有用的话欢迎持续关注,我大概一天更一节,有事除外。格式什么的我也就不做了,翻译都是我自己翻译的,哪里不对欢迎在评论区指正,感谢各位大佬支持 这一章叫做Animations UIKit提供内置动画的属性,根据值的

Programmer_Roy的博客 1506

python批量调用大模型API:多线程和异步协程

本文介绍了利用多线程技术批量调用大模型API的实现方法。核心是通过并发请求提高处理效率,主要采用线程池管理并发数量、结果聚合等技术。文章提供了一个完整的Python实现示例,包含APIBatchCaller类及其single_api_call和batch_call方法,详细解析了并发控制、错误处理等关键点,并给出了使用注意事项,包括并发数设置、重试策略和超时处理等。该方案特别适合IO密集型任务,能显著提升批量API调用的效率。

Cachel Wood的博客 760

UIKit学习笔记1

记录了学习UIKit需要注意的事项,可以加深你对swift语言的理解

wtt561111的专栏 745

安卓刷Windows太难?这款手机平板双系统刷机工具,小白也能轻松拿捏!(小白福音!手机平板专用,一键搞定安卓刷 Windows 双系统!)

安卓刷Windows太难?这款手机平板双系统刷机工具,小白也能轻松拿捏!(小白福音!手机平板专用,一键搞定安卓刷 Windows 双系统!)

XiaoqiangClub的博客 4685

【感知模块算法】障碍物detect+trace+prediction方向介绍

系列文章目录 提示:这里可以添加系列文章的所有文章的目录,目录需要自己手动添加 TODO:写完再整理 文章目录系列文章目录前言一、多维度看感知问题,体会复杂性二、障碍物/环境目标detect方向1.视觉目标检测方向(1)图像处理认知(2)视觉基础理论部分1、获取数据集---python网页爬虫、买数据、自己录数据、使用开源比赛的数据集2、opencv库的学习3、深度学习框架学习(3)视觉目标检测理论(1)目标检测的概念(2)目标检测的应用场景(3)现有目标检测框架原理及论文【这仅仅是我当初入门学习的框架~

qq_35635374的博客 2895

View Programming Guide for IOS:View and Window Architecture笔记

View 和 Core Animation layers 连结起来渲染和动画view的内容。每个UIKit框架内的view的背后都是一个layer对象(一般是CALayer的实例),这个layer管理view背后的存储并且操作跟view有关的动画。大部分的操作都可以通过UIView的接口来执行,但是如果需要更多的操作来渲染或给视图做动画,也可以直接对layer做操作。 在laye

jinangzhu的专栏 818

【AI智能体】QClaw 对接GitHub处理自动化任务实战操作详解

QClaw 对接GitHub处理自动化任务实战操作详解

congge 4873

View Programming Guide for iOS ---- iOS 视图编程指南(二)---View and Window Architecture

View and Window Architecture 视图和窗口架构 Views and windows present your application’s user interface and handle the interactions with that interface. UIKit and other system frameworks provide a n...

319

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

Unity游戏开发框架QFramework实战:MVC架构与数据驱动UI设计

在Unity游戏开发中,MVC(Model-View-Controller)架构模式是解决代码混乱、提升可维护性的经典方案。其核心原理在于分离数据、表现与控制逻辑,让各层职责清晰。通过数据绑定技术,可以实现Model数据变化时View自动更新,极大减少手动同步的胶水代码。这种架构的技术价值在于提升团队协作效率、降低维护成本,尤其适合UI界面复杂、状态繁多的项目。应用场景涵盖从独立开发到中小团队的游戏项目,能有效管理角色状态、背包系统等模块。本文以QFramework框架为例,深入解析其如何将MVC模式适配U

weixin_34301132的博客 428

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

IOS开发之通过官网系统学习UIKit

IOS开发之通过官网系统学习UIKit                 相信大家从事移动端开发,会买大量的资料去学习,其实我也是这样的,不光花了钱去买书籍  还花了一笔钱去参加培训之类的。随着自己慢慢逐渐走入开发的岗位,很多资料官网上面还是比较详细的,比说说安卓,google官网比较全面的说明文档,通过那个文档可以完全掌握安卓开发,安卓各个版本的SDK都有相关的示例代码。其实自己想学习I

wangliang198901的专栏 1638

uikit学习

*)ur-drop组件:在元素旁边显示一个框   delay-hide:1000(鼠标移开后1000毫秒才唤醒结束操作,默认是800)   delay-show:1000(点击后过1000毫秒才会出现东西)   参考链接:https://getuikit.com/docs/drop    ...

houpainansheng688的博客 269

UIKit框架基础

UIKit是Cocoa Touch的一部分,提供了一组类来创建和管理iOS App的窗口和视图、处理事件、绘图和动画等。常用的UIKit组件有UIView及子类,包括UIScrollView(UITableView、UICollectionView、UITextView)、UILabel、UIControl(UIButton、UITextField)、UIPickerView等;与控件相关但不能被人所直观看到的图形、绘图、打印、文本等的配置与控制。...

ZCF_093的博客 5125

cocoa touch框架UIkit学习

iOS中框架就是一个目录,这个目录包含了共享库,可以访问共享库的头文件,和其他图片声音等资源,可以被应用程序所调用.应用程序可以使用很多框架,这些框架构成了IOS操作系统的层次架构,一共分为四层,从上到下依次为:Cocoa Touch Layer(触摸UI层)、MediaLayer(媒体层)、Core Services Layer(核心服务层)、Core OS Layer(核心OS层)。

peanut的博客 1296

UIKit的简单入门介绍

后续文章将进行IOSUI开发的介绍。第一个则是基础控件——标签 - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. //初始化一个label UILabel* lab = [[UILabel alloc]initWithFram...

走过路过不要错过 3156

Qframework框架使用之UIKit Event

一.简介 1.背景        UIKit中UIRoot预制体中将UI共分了十一层,为了解耦合,UIkit专门为不同层级不同panel之间的交互提供了专门的事件系统. 2.功能       用于不同Panel之间的交互. 二.使用       案例效果如下,点击Setting面板的ChangeMenuColor按钮改变Menu面板背景颜色:  1. 新建enum设置好Event...

千喜 1538

UIKit

UIKit框架提供一系列的Class(类)来建立和管理IOS应用程序的用户界面(UI)接口、应用程序对象、事件控制、绘图模型、窗口、视图和用于控制触摸屏等的接口。可以理解成是苹果提供给开发和来操纵程序和界面的一个API库。

枫叶雪 2531

QFramework (v0.0.9)入门学习(一) UIKit

"Version": "v0.0.9" 因为笔者水平有限,加之也最近才开始接触这个框架,不足之处,请多多指教。 框架github下载地址:https://github.com/liangxiegame/QFramework 框架作者文档:http://qframework.io/ 1. 将框架预设体 UIRoot 添加到面板 2.在 Design 里面新建一个 panel ,我这取名...

我知道你很急,但是路要一步步走 3474

Swift 字面量详解:从基础语法到实战技巧

Swift字面量是源代码中直接书写的固定值,如42、"Hello"、true等,其类型由上下文推断。整数支持十进制、二进制、八进制及十六进制写法,并可用下划线提升可读性;浮点默认为Double,支持科学计数法与十六进制表示。字符串支持转义、多行与插值,原始字符串避免转义。字符需显式标注类型,数组与字典字面量需配合类型推断。nil仅用于可选类型。通过ExpressibleBy...协议,自定义类型也可支持字面量初始化。理解字面量的类型推断机制,有助于编写更安全、清晰的Swift代码。

2402_85743155的博客 326

Swift 常量详解:从 let 到编译期优化

Swift中,常量使用let声明,一旦赋值不可更改,强调代码安全与可读性。推荐优先使用let,仅在需要变化时用var。常量支持类型推断或显式声明,可存基本类型、集合、元组、可选值及引用类型。注意:let仅锁定引用,不锁定对象内部状态。合理使用常量有助于编译器优化,提升性能。最佳实践包括默认使用let、命名清晰、全局常量集中管理。养成“默认let、按需var”习惯,是写出高质量Swift代码的关键。

2402_85743155的博客 141
下一篇: UIKit学习笔记—第二节Windows
诚是张嘉诚
博客等级 码龄7年 15粉丝 24原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值