-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
normal模式也转换成实时滤镜,提高切换的效率,并且重构了切换滤镜的UI
- Loading branch information
1 parent
6c9eaf7
commit 49df353
Showing
11 changed files
with
435 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+19.8 KB
(130%)
...roj/project.xcworkspace/xcuserdata/chenzhiying.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
MeiPaiDemo/MeiPaiDemo/Assets.xcassets/back.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "[email protected]", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Binary file added
BIN
+1.79 KB
MeiPaiDemo/MeiPaiDemo/Assets.xcassets/back.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// Common.swift | ||
// MeiPaiDemo | ||
// | ||
// Created by 陈智颖 on 15/10/18. | ||
// Copyright © 2015年 YY. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
|
||
struct CommonColor { | ||
static let mainColor = UIColor(red: 255/255, green: 102/255, blue: 102/255, alpha: 1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// | ||
// FilterScrollView.swift | ||
// MeiPaiDemo | ||
// | ||
// Created by 陈智颖 on 15/10/17. | ||
// Copyright © 2015年 YY. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class FilterScrollView: UIView { | ||
|
||
private var scrollView: UIScrollView! | ||
private var filterLabels = [UILabel]() | ||
|
||
private var filters = [CIFilter?]() | ||
private var currentFilterIndex = 0 | ||
private let maxCountInScreen = 3 | ||
|
||
// MARK: - Life Cycle | ||
private override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
} | ||
|
||
required init?(coder aDecoder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
convenience init(frame: CGRect, filters: [CIFilter?]) { | ||
self.init(frame: frame) | ||
|
||
self.filters = filters | ||
initView() | ||
} | ||
|
||
func initView() { | ||
|
||
func initScrollView() { | ||
scrollView = UIScrollView(frame: CGRectMake(frame.origin.x + frame.size.width / CGFloat(maxCountInScreen) , 0, frame.size.width / CGFloat(maxCountInScreen), frame.size.height)) | ||
scrollView.scrollEnabled = false | ||
scrollView.clipsToBounds = false | ||
} | ||
|
||
func changeFilterToLabel() { | ||
guard filters.count > 0 else { return } | ||
var count = 0 | ||
filterLabels = filters.map { filter -> UILabel in | ||
let label = UILabel(frame: CGRectMake(scrollView.frame.width * CGFloat(count++) , 0, scrollView.frame.width, scrollView.frame.height)) | ||
label.text = filter == nil ? "Normal" : (filter!.name as NSString).substringFromIndex(13) | ||
label.textColor = UIColor.grayColor() | ||
label.font = UIFont.systemFontOfSize(13) | ||
label.textAlignment = .Center | ||
scrollView.addSubview(label) | ||
return label | ||
} | ||
|
||
filterLabels[currentFilterIndex].textColor = CommonColor.mainColor | ||
filterLabels[currentFilterIndex].font = UIFont.systemFontOfSize(15) | ||
} | ||
|
||
initScrollView() | ||
changeFilterToLabel() | ||
scrollView.contentSize = CGSizeMake(CGFloat(filterLabels.count) * scrollView.frame.width, scrollView.frame.height) | ||
addSubview(scrollView) | ||
|
||
} | ||
|
||
// MARK: - Public | ||
func changeFIlterByPlus(plus: Bool) { | ||
|
||
filterLabels[currentFilterIndex].textColor = UIColor.grayColor() | ||
filterLabels[currentFilterIndex].font = UIFont.systemFontOfSize(13) | ||
|
||
if plus { | ||
guard currentFilterIndex < filterLabels.count - 1 else { return } | ||
currentFilterIndex++ | ||
} else { | ||
guard currentFilterIndex > 0 else { return } | ||
currentFilterIndex-- | ||
} | ||
|
||
filterLabels[currentFilterIndex].textColor = CommonColor.mainColor | ||
filterLabels[currentFilterIndex].font = UIFont.systemFontOfSize(15) | ||
scrollView.setContentOffset(CGPointMake(CGFloat(currentFilterIndex) * scrollView.frame.width, 0), animated: true) | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.