资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

ios基础UI-创新互联

Let常量
Var 变量
.dynamicType 类型
Print(a,b,terminator:”;”)结尾符为;,默认是换行

创新互联是专业的志丹网站建设公司,志丹接单;提供做网站、网站制作,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行志丹网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!

Sizeof(Type)
类型.min 类型.max 获取到类型大和最小的值

字符串插值 \(…可以进行操作,作为整体)

Var str = “123”
Str.startIndex ->0
Str.endIndex ->2

字符串长度使用 String.characters.count 属性来计算

Var oneArrar = Array()
Var oneArrar = [Int]()
Var oneArrar = Int -> [0,0,0]
Var oneArray = [0,0,0]
Var oneArray = twoArray + threeArray
访问
oneArray[0]
添加
oneArray.append(40)
oneArray += [50,60]
oneArray.insert(70,atIndex:0) 在任意有效索引前面添加
oneArray.removeAtIndex(0) 删除索引上的值

无序集set:存储相同类型的无序、不重复,元素必须是hashcode
有自身的hashValue
let myset = Set()
let myset = Set([“1”,”2”,”3”])
let myset = Set([“1”,”2”,”3”]) -> {“1”,”2”,”3”}
let myset = Set([“1”,”2”,”1”]) ->{“1”,”2”}

myset.insert(“sfdf”)
myset.remove(“sfdf”)
for item in myset.sort(){
print(item)
}
Myset.count
Myset.isEmpty
Contians(sfdf)
Let res = seta.intersect(setb) 交集
Let res2 = seta.union(setb) 并集

Dictionary 字典 键值对
Tuole 元祖 把多个值合成一个复合值,元祖内的值可以任意的,可以不同或相同

Let dict1 = Dictionary()
Let dict1 = [Int,Int]()
Var lessonDict : [String:String] = [“1”:”one”,”2”,”two”]
lessonDict[“1”]
lessonDict.[“3”] = “three” key如果不存在就会把key-value添加进去
删除
lessonDict.removeValueForKey(“1”)
lessonDict[“1”] = nil
遍历
For(key,vlaue) in lessonDict{
Print (key,vale)
}

Tupe 元祖
Let mytuple = (“1”,”2”)
Let (lessonIndex,lessonName) = mytuple 分解元祖
Mytuple.0 获取到第一个元素

区间运算符
1…5
1..<5

Optional
类型:包含两种状态,有某个值,或者为空nil
Var age : Optional <==> var age : Int?
let I : Int? =20

函数
func 函数名(参数名:参数类型) -> 返回值类型 {

}

调用函数,多个形参的时候,需要带上形参名
add(1,num2: 2)

func say(person person)

函数类型由参数类型和返回值类型确定
定义一个函数类型
Var func = addfunc (Int,Int)->Int

函数类型作为参数类型

闭包自包含的函数代码块,函数是一种闭包
闭包还有一种叫闭包表达式
{(参数类型) –>返回类型 in

}

let add = {(a : Int,b : Int) -> Int in return a + b}
{(a : Int,b : Int) -> Int in return a + b} 匿名函数
{$0 + $1}

尾随闭包

UILabel
程序入口是application的didiFinishLaunchingWithOptions里循环进行的;
LaunchScreen.storyboard预加载画面
Let label : UILabel = UILabel(frame : CGRectMake(x,y,leng,width))
Label.text = “is a label”
Label.font = UIFont()
Label.textColor = UIColor()
Label.backgroundColor = …
Label.textAlignment = NSTextAlignment.Center
Label.shadowColor = UICollor…. 设置阴影
Label.shadowOffset = CGSzieMake(10,10) 设置偏移量
Label.numberOfLines = 2 设置行数 设置为0为无限行
Self.view.addSubview(label)加载到视图上

UIBotton
Let button:UIButton UIButton(type: UIButtonType.System) 设置button类型 枚举很多类型
Custom 自定义无类型
System 系统标准类型
InfoDark 详情样式
ContactAdd 添加类型
Button.frame=CGRectMake(10,10,100,100)
//添加事件
Button.addTarget(selft,action:Selector(“click”),forControlEvents:UIControlEvents.TouchUpInside)
Button.contentEdgeInsets = UIEdgeInsetsMake(-10,-10,0,0) 设置内容的偏移量
Button.setImage(UIImage(named:1.jpg),forState:UIControlState.Normal) //并行 (图片-文字)
Button.setBackgroundImage(UIImage(named:1.jpg),forState:UIControlState.Normal)//文字会在图片上面

Self.view.addSubview(button)

//点击执行的函数
Func click(btn:UIButton){
Btn.backgroundColor = UIColor(red : (CGFloat)(random()%255)/255,green:34,blue:34,alpha:1)
}

UIImageView
Let imageView:UIImageView = UIImageView(frame:CGRectMake(100,100,100,100))
imageView.image = UIImage(named: “1.png”)
imageView.hightlightedImage //设置高亮图片
imageView.highlighted = true//设置为高亮状态
var array:Array = Array()
for var i=0;i<3;i++{
let image:UIImage? = UIImage(named: String(format:”%d.png”,i))
array.append(image!)
}
imageView.animationImages = array as ? [UIImage]//设置imageView的动画数组
imageView.animationRepeatCount = 0 设置动画的播放次数 0 无限
imageView.animationDuration = 3 设置一轮播放时间3秒
imageView.startAnimating() 开始播放动画
set.view.addSubview(imageView)

layer属性
imageView.layer.masksToBounds=true//设置圆角
imageView.layer.cornerRadius = 50
imageView.layer.borderWidth = 2 设置边框
imageView.layer.borderColor = UIColor.greenColor()
imageView.layer.shadowColor = … 设置阴影
imageView.layer.shadowOffset = CGSizeMake(10,10)
imageView.layer.shadowOpacity =1; 设置不透明

UISearchBar
Let searchBar:UISearchBar = UISearchBar()
searchBar.placeholder = “请输入关键字” // 设置默认提示语
searcBar.text = “剑圣” //设置默认文字
searchBar.barStyle = UIBarStyle.()设置风格
searchBar.prompt = “” 背景文字(title作用)
searchBar.showsBookmarkButton=true 设置相应功能按钮的显示与否
searchBar.tintColor 设置光标等渲染颜色
searchBar.barTintColor 设置搜索框背景颜色

http://www.maiziedu.com/course/710-10351/ 未

UISwitch
mySwitch.thumbTintColor… 设置滑块的颜色
添加事件

UISegementControl
Let seg: UISegementControl = UISegementControl()
Seg.insertSegmentWithTile(“第一个按钮”,atIndex:0,animated:true)设置分段控制器
Seg.addTarget(selft,action: Selector(“clickSeg:”),forControleEvents:UIControlEvents.ValueChange)
Seg.momentary = false true 设置是否保持选择状态

touchesBegan()

func clickSeg(seg: UISegementControl){

}

bringSubviewToFront(viewBlue) 把某个view放在最上面

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网页标题:ios基础UI-创新互联
文章来源:http://cdkjz.cn/article/cdpsde.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220