Page-Base Application :
作为一个电子书的应用模板
1关于数据源,首先查看到RootViewController的ViewDidLoad方法的一个datasource来源——ModelController
2ModelController方法的初始方法提供了数据的来源和显示内容
Master-Detail Application:
作为一个记事本的应用提供模板
这里有各种的item的添加方法
匹配父级容器:
父级容器说的是视图所在的容器,通过设置上下左右的边距使它适应各种的屏幕尺寸
通过editor—> pin 设置上下左右的边距
分割父级容器:
要求:分割的容器能适应屏幕的旋转——>通过设置边距线
不同子容器之间的间距的是通过不同的水平间距
父容器内子容器要按一定比例,记得设置父容器与view的边距,第一个viewcontroller相当于是所有建立在它上面的所有view的父容器
自定义圆型进度指示 ---这个例子说明
import UIKit
class progresscustom: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
self.backgroundColor = UIColor(white: 1, alpha: 0)
}
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private var _progressValue :CGFloat = 0
internal func getProgressVlue() ->CGFloat{
return _progressValue ;
}
internal func setProgressValue(value : CGFloat){
_progressValue = value ;
setNeedsDisplay() ;
}
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.当子图需要表现在VIew上的时候,需要重写这个方法
override func drawRect(rect: CGRect) {
// Drawing code
var ctx = UIGraphicsGetCurrentContext() ;
var r = rect.width/2
CGContextAddArc(ctx,r, r, r, 0, 3.1415926*2, 0)
CGContextAddLineToPoint(ctx, r, r)
CGContextSetRGBFillColor(ctx, 0.7, 0.7, 0.7, 1)
CGContextFillPath(ctx)
CGContextAddArc(ctx,r, r, r, 0, 3.1415926*2*_progressValue, 0)
CGContextAddLineToPoint(ctx, r, r)
CGContextSetRGBFillColor(ctx, 0, 0, 1, 1)
CGContextFillPath(ctx)
CGContextStrokePath(ctx)
CGContextSetLineWidth(ctx, 5)
}
实时预览自定义控件效果:
可以为控件添加自己设置的属性
1:这个属性要在属性窗访问到,要先在project后面上 Add Target —Cocoa touch framework
2 在这个framework下添加类,在类前添加关键字 @IBDesignable
3每一个需要添加的属性都需要添加关键字@IBInspectable
4属性里有个 didSet 。。。。。layer是原属性用的主体上
5对storyboard上的控件加上上述的类 ,然后可以在这个属性inspector上查看到
IOS视图切换 :图片之间的切换----静态方法
UIView.transitionFromView(cyndi1, toView: cyndi2, duration: 1, options: UIViewAnimationOptions.TransitionFlipFromLeft, completion: nil)
通过上述方法来从cyndi1 切换到cyndi2 ,option是切换方式,completion是切换过程执行的函数,可以是nil
当然通过设置一个bool值可以在两张图片直接来回切换
IOS视图动画效果
1先设置动画效果
UIView.beginAnimations(nil ,context : nil)//必须
//设置属性
UIView.seAnimationTransition(UIViewAnimationTransition.CurlDown. ,...)
UIView.setAnimationDuration(1.0)
2最后一定提交 UIView.commitAnimations()
IOS自定义动画
UIView.transitionWithView()来设置
转载于:https://www.cnblogs.com/KyleRuan/p/4296135.html