随笔分类 - Swift基础
摘要:import UIKit class ViewController: UIViewController {//定义通知的名字,Notification 的“名字”不再是字符串类型,而是 Notification.Name 类型 let myNotification = Notification.Na
阅读全文
摘要:import UIKit class SharedInfo: NSObject { var nameStr:String? = "123" //设置初始值 struct ToolP { static var myTool:SharedInfo?=nil } class func shareMyToo
阅读全文
摘要:import UIKit 导入此框架 扩展的格式 extension + 需要扩展的类名{ } 以下是对数据持久化UserDefaults的扩展代码 extension UserDefaults{ enum TestData: String,UserDefaultSettable{ case nam
阅读全文
摘要:枚举类型的格式 enum direction { case North case South case East case West } 一个枚举中被定义的值是枚举的成员值(例如:North ,South,East,West)。 定义一个新的枚举类型,它的名字必须以一个大写字母开头。 我们用关键字c
阅读全文
摘要:委托是一种设计模式,它允许类或结构体将一些需要它们负责的功能交由给其他的类型 委托模式的实现很简单: 定义协议来封装那些需要被委托的函数和方法,使其遵循着拥有这些被委托的函数和方法 //制定需要遵守的协议,制定协议遵守NSObjectProtocol协议 protocol bottomViewDel
阅读全文
摘要:import UIKit class ViewController: UIViewController { var button : UIButton! var array = NSMutableArray() override func viewDidLoad() { super.viewDidL
阅读全文
摘要://字符串的替换 let ReplaceString = "http://www.aimonkey。cn" let FilterReplace = ReplaceString.replacingOccurrences(of: "。", with: ".") print(FilterReplace)
阅读全文
摘要://UI界面代码 import UIKit class CameraView: UIView { var cameraButton : UIButton! var photoButton : UIButton! var image : UIImageView! override init(frame
阅读全文
摘要://Swift 提醒框 let alert = UIAlertController(title:"提示", message:"用户名或密码错误", preferredStyle: .alert) let cancel = UIAlertAction(title: "取消", style: .canc
阅读全文
摘要:// let bt = UIButton(frame:CGRectMake(10,20,50,50)) let button = UIButton(frame:CGRectMake(10, 150, 100, 30)) //初始化按钮和设置按钮位置与大小 button.backgroundColor
阅读全文
摘要:let label = UILabel(frame:CGRect(x: 20,y: 100,width: 280,height: 40)) label.text = "理想接电话是否很沮丧和甲方狙击手的开发可谓文件的附件二反馈句" label.backgroundColor = UIColor.bl
阅读全文

浙公网安备 33010602011771号