TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Jul 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Hemang Shah.
Another rating view to share your feelings.
IMPORTANT: You will need two images, one is filled and another is unfilled to represents feelings. See this sample images for the same, check it here.
1.Manually - Add FeelingsView.swift
class to your Project. All set.
2.CocoaPods:
source 'https://github.com/CocoaPods/Specs.git'
target 'Sample' do
use_frameworks!
pod 'FeelingsView', '~>1.0'
end
//Create Sample Arrays
let rows = ["Quality","Price","Value"]
let columns = ["1 Star","2 Star","3 Star","4 Star","5 Star"]
//Create FeelingsView
//Note: You should provide two images for FeelingsView. 1. Filled and 2. Unfilled
let viewFeeling = FeelingsView.init(frame: CGRect.init(x: 0.0, y: 0.0, width: 300.0, height: 200.0))
viewFeeling.backgroundColor = UIColor.clear
viewFeeling.autoresizingMask = [.flexibleLeftMargin, .flexibleRightMargin, .flexibleTopMargin, .flexibleBottomMargin]
self.view.addSubview(viewFeeling)
viewFeeling.center = self.view.center
//Setting fill/unfill images for FeelingsView
viewFeeling.fillImage = UIImage.init(named: "filled.png")!
viewFeeling.unfillImage = UIImage.init(named: "unfilled.png")!
//Setting up values for Feelings
viewFeeling.columnTitles = columns
viewFeeling.rowTitles = rows
//Reload
viewFeeling.reloadFeelingView()
//Detect selection of Feelings value
viewFeeling.onFilledCompletion = { (row,column) in
//Note: row and column are the Int which a user tapped in the FeelingsView
let rowValue = rows[row]
let columnValue = columns[column]
print("\(rowValue) -> \(columnValue)")
}
IMPORTANT: For customizations see the example.
Add a UIView
. Set require size. Add constraints if requires.
Change class type from UIView
to FeelingsView
.
FeelingsView
.Create an IBOutlet
for FeelingsView
. Bind it in IBInspector
.
In viewDidLoad
or at anyplace where you want provide rows and columns titles.
Reload FeelingsView
by calling reloadFeelingView
function.
Detect the taps on FeelingsView
by implementing onFilledCompletion
closure block.
You can watch to Feelings to see continuous updates. Stay tuned.
Have an idea for improvements of this class? Please open an issue. Â Â
You can shoot me an email to contact.
The MIT License (MIT)
Read the LICENSE file for details.