总结:记不住的代码

self.center = (touches.first?.locationInView(self.superview))!

override func touchesBegan(touches: Set, withEvent event: UIEvent?) {

// 停止UIView动画

    self.imagView.layer.removeAllAnimations()

// 让形变清空
self.imagView.transform = CGAffineTransformIdentity
}

self.tabBar.translucent = false

//2.设置中间的文字颜色
//NSForegroundColorAttributeName 文字颜色的key
self.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.whiteColor()]

// 需要显示在Label上的文字
let str = "有的防护服的发挥份发动机减肥哈将对方尴尬发动 "

// 计算显示指定文字所需要的最小空间
// 1.将swift的字符串转换成oc的字符串
let ocStr = str as NSString
// 2.计算字符串大小
// 参数1:限制显示当前字符串当前字符串的最大宽度和最大高度
// 参数2:设置渲染方式
// (UsesLineFragmentOrigin)
// 参数3:确定文字的字体(大小)
// NSFontAttributeName -> 字体对应的Key值
// NSForegrouundColorAttributeName -> 文字颜色对应的Key值
let strSize = ocStr.boundingRectWithSize(CGSizeMake(200, 100000), options: .UsesLineFragmentOrigin, attributes: [NSFontAttributeName: UIFont.systemFontOfSize(17)], context: nil).size
print(strSize)

// 创建label显示文字
let label = UILabel.init(frame: CGRectMake(100, 100, strSize.width, strSize.height))
label.backgroundColor = UIColor.yellowColor()
self.view.addSubview(label)
label.text = str
// 自动换行
label.numberOfLines = 0 //必须要自动换行,不然会一行显示
}

 board = [[PointState]](count: 15, repeatedValue: [PointState](count: 15, repeatedValue: .Space))

//
// TapViewController.swift
// 02-手势集合
//
// Created by 千锋1 on 16/9/2.
// Copyright © 2016年 1000phone. All rights reserved.
//

import UIKit

class TapViewController: YTViewController {

override func viewDidLoad() {
    super.viewDidLoad()

// 1.创建点击手势对象
// UIGestureRecongnizer是所有手势的父类
// 参数1.调用方法的对象
// 参数2.方法对应的选择器 -> 这个方法如果带参只能带一个参数,参数的对象就是当前创建的点击手势对象
// 点击手势发生的时候让参数1调用参数2中的方法

    let tap = UITapGestureRecognizer.init(target: self, action: "tapActon:")
    
    //核心属性:点击次数(默认是1->单击)
    tap.numberOfTapsRequired = 2

// 2.将点击手势添加到视图上(要求:添加手势的视图必须可以进行用户交互)
self.view.addGestureRecognizer(tap)

// 3.打开图片的用户交互,并添加点击手势
// 注意:同一个手势对象,只能被添加到一个视图
self.imagView.addGestureRecognizer(tap)
}

func tapAction(tap:UITapGestureRecognizer) {
    
    print("点击")
    
    if self.imagView.frame.size.width == 200 {
        self.imagView.frame = self.view.bounds

    }
    else {
        self.imagView.frame = CGRectMake(0, 0, 200, 200)
        self.imagView.center = self.view.center
    }
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
   
}

}

你可能感兴趣的:(总结:记不住的代码)