生活随笔
收集整理的這篇文章主要介紹了
第五周个人预习
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
/// 訪客登錄視圖 class VisitorLoginView: UIView {
override init(frame: CGRect) {super.init(frame: frame)backgroundColor = UIColor.redColor()
}required init(coder aDecoder: NSCoder) {fatalError("init(coder:) has not been implemented")
}
復制代碼 }
* 修改 `setupVisitorView` 函數```swift
// 替換根視圖
view = VisitorLoginView()
復制代碼
private func setupUI(){addSubview(iconView)addSubview(homeIconView)addSubview(messageLabel)addSubview(registerButton)addSubview(loginButton)}
private lazy var iconView:
UIImageView = {
let iv =
UIImageView(image:
UIImage(named:
"visitordiscover_feed_image_smallicon"))
return iv}()
private lazy var homeIconView:
UIImageView = {
let iv =
UIImageView(image:
UIImage(named:
"visitordiscover_feed_image_house"))
return iv}()
private lazy var messageLabel:
UILabel = {
let label =
UILabel()label.text =
"關注一些人,回這里看看有什么驚喜"return label}()
private lazy var registerButton:
UIButton = {
let btn =
UIButton()btn.setTitle(
"注冊", forState:
UIControlState.
Normal)
return btn}()
private lazy var loginButton:
UIButton = {
let btn =
UIButton()btn.setTitle(
"登錄", forState:
UIControlState.
Normal)
return btn}()
復制代碼 iconView.xmg_AlignInner(type:
XMG_AlignType.
Center, referView:
self, size:
nil)homeIconView.xmg_AlignInner(type:
XMG_AlignType.
Center, referView:
self, size:
nil)messageLabel.xmg_AlignVertical(type:
XMG_AlignType.
BottomCenter, referView: iconView, size:
nil)addConstraint(
NSLayoutConstraint(item: messageLabel, attribute:
NSLayoutAttribute.
Width, relatedBy:
NSLayoutRelation.
Equal, toItem:
nil, attribute:
NSLayoutAttribute.
NotAnAttribute, multiplier:
1.0, constant:
224))registerButton.xmg_AlignVertical(type:
XMG_AlignType.
BottomLeft, referView: messageLabel, size:
CGSize(width:
100, height:
35), offset:
CGPoint(x:
0, y:
20))loginButton.xmg_AlignVertical(type:
XMG_AlignType.
BottomRight, referView: messageLabel, size:
CGSize(width:
100, height:
35), offset:
CGPoint(x:
0, y:
20))
復制代碼 private lazy var iconView:
UIImageView = {
let iv =
UIImageView(image:
UIImage(named:
"visitordiscover_feed_image_smallicon"))
return iv}()
private lazy var homeIconView:
UIImageView = {
let iv =
UIImageView(image:
UIImage(named:
"visitordiscover_feed_image_house"))
return iv}()
private lazy var messageLabel:
UILabel = {
let label =
UILabel()label.text =
"關注一些人,回這里看看有什么驚喜"label.textColor =
UIColor.darkGrayColor()label.font =
UIFont.systemFontOfSize(
14)label.numberOfLines =
0label.sizeToFit()
return label}()
private lazy var registerButton:
UIButton = {
let btn =
UIButton()btn.setTitle(
"注冊", forState:
UIControlState.
Normal)btn.setBackgroundImage(
UIImage(named:
"common_button_white_disable"), forState:
UIControlState.
Normal)btn.setTitleColor(
UIColor.orangeColor(), forState:
UIControlState.
Normal)
return btn}()
private lazy var loginButton:
UIButton = {
let btn =
UIButton()btn.setTitle(
"登錄", forState:
UIControlState.
Normal)btn.setBackgroundImage(
UIImage(named:
"common_button_white_disable"), forState:
UIControlState.
Normal)btn.setTitleColor(
UIColor.orangeColor(), forState:
UIControlState.
Normal)
return btn}()
復制代碼 private lazy var maskIconView:
UIImageView = {
let iv =
UIImageView(image:
UIImage(named:
"visitordiscover_feed_mask_smallicon"))
return iv}()
復制代碼 maskIconView.xmg_Fill(
self)
復制代碼backgroundColor =
UIColor(white:
237.0 /
255.0, alpha:
1.0)
復制代碼正則表達式
在編寫處理字符串的程序時,經常會有查找符合某些復雜規則的字符串的需要。正則表達式就是用于描述這些規則的工具。換句話說,正則表達式就是記錄文本規則的代碼
正則表達式是對字符串操作的一種邏輯公式,用事先定義好的一些特定字符、及這些特定字符的組合,組成一個"規則字符串",這個"規則字符串"用來表達對字符串的一種過濾邏輯。
-在很多文本編輯器里,可以使用正則表達式進行檢索,Xcode同樣支持正則表達式! -幾乎所有的程序設計語言都支持正則表達式,例如:OC,java,c#,python,js等。 常用正則表達式:http://www.cnblogs.com/zxin/archive/2013/01/26/2877765.html
NSRegularExpressionCaseInsensitive = 1 << 0, 忽略大小寫 NSRegularExpressionAllowCommentsAndWhitespace = 1 << 1, 忽略空白字符,以及前綴是 # 開始的注釋 NSRegularExpressionIgnoreMetacharacters = 1 << 2, 將整個匹配方案作為文字字符串 NSRegularExpressionDotMatchesLineSeparators = 1 << 3, 允許 . 匹配任意字符,包括回車換行 NSRegularExpressionAnchorsMatchLines = 1 << 4, 允許 ^ 和 $ 匹配多行文本的開始和結尾 NSRegularExpressionUseUnixLineSeparators = 1 << 5, 僅將 \n 作為換行符 NSRegularExpressionUseUnicodeWordBoundaries = 1 << 6 使用 Unicode TR#29 指定單詞邊界
url正則:"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?"
0> 匹配
(pattern) 匹配pattern并獲取這一匹配,所獲取的匹配可以從產生的Matches集合得到
1> 常用元字符
. 匹配除換行符以外的任意字符 \w 匹配字母或數字或下劃線或漢字 \s 匹配任意的空白符(空格、TAB\t、回車\r \n) \d 匹配數字
^ 匹配字符串的開始 $ 匹配字符串的結束 \b 匹配單詞的開始或結束
2> 常用反義符
\W 匹配任意不是字母,數字,下劃線,漢字的字符 \S 匹配任意不是空白符的字符 \D 匹配任意非數字的字符
\B 匹配不是單詞開頭或結束的位置 [^x] 匹配除了x以外的任意字符 [^aeiou] 匹配除了aeiou這幾個字母以外的任意字符
3> 集合
[xyz] 字符集合 [^xyz] 負值字符集合 [a-z] 字符范圍 [^a-z] 負值字符范圍
4> 常用限定符
? 重復零次或一次 {n} 重復n次 {n,} 重復n次或更多次 {n,m} 重復n到m次
5> 貪婪和懶惰
*? 重復任意次,但盡可能少重復 *+ 重復1次或更多次,但盡可能少重復 ?? 重復0次或1次,但盡可能少重復 {n,m}? 重復n到m次,但盡可能少重復 {n,}? 重復n次以上,但盡可能少重復
總結
以上是生活随笔為你收集整理的第五周个人预习的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。