diff --git a/iOSTemplate.xcodeproj/project.pbxproj b/iOSTemplate.xcodeproj/project.pbxproj index 1cf913069812975eebcb2f25e74085424a0eda6d..eb449be3c528bdff6ab7cdbcd2d995a38ff44391 100644 --- a/iOSTemplate.xcodeproj/project.pbxproj +++ b/iOSTemplate.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 37154FE2222CBCFE006731A8 /* RatingControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37154FE1222CBCFE006731A8 /* RatingControl.swift */; }; 3775361422234238005EE5FE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3775361322234238005EE5FE /* AppDelegate.swift */; }; 3775361622234238005EE5FE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3775361522234238005EE5FE /* ViewController.swift */; }; 3775361922234238005EE5FE /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3775361722234238005EE5FE /* Main.storyboard */; }; @@ -34,6 +35,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 37154FE1222CBCFE006731A8 /* RatingControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RatingControl.swift; sourceTree = ""; }; 3775361022234238005EE5FE /* iOSTemplate.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iOSTemplate.app; sourceTree = BUILT_PRODUCTS_DIR; }; 3775361322234238005EE5FE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 3775361522234238005EE5FE /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; @@ -100,6 +102,7 @@ 3775361322234238005EE5FE /* AppDelegate.swift */, 3775361522234238005EE5FE /* ViewController.swift */, 3775361722234238005EE5FE /* Main.storyboard */, + 37154FE1222CBCFE006731A8 /* RatingControl.swift */, 3775361A22234238005EE5FE /* Assets.xcassets */, 3775361C22234238005EE5FE /* LaunchScreen.storyboard */, 3775361F22234238005EE5FE /* Info.plist */, @@ -256,6 +259,7 @@ buildActionMask = 2147483647; files = ( 3775361622234238005EE5FE /* ViewController.swift in Sources */, + 37154FE2222CBCFE006731A8 /* RatingControl.swift in Sources */, 3775361422234238005EE5FE /* AppDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/iOSTemplate/Base.lproj/Main.storyboard b/iOSTemplate/Base.lproj/Main.storyboard index a444e525c3500fc8857e1a64b3d64c450792c6c3..6460871fafc9edccce13e263aa2e480f414ae42b 100644 --- a/iOSTemplate/Base.lproj/Main.storyboard +++ b/iOSTemplate/Base.lproj/Main.storyboard @@ -18,8 +18,8 @@ - - + + diff --git a/iOSTemplate/RatingControl.swift b/iOSTemplate/RatingControl.swift new file mode 100644 index 0000000000000000000000000000000000000000..ab218bec37e3b06826bd19d1652e2d3bcd8b77b8 --- /dev/null +++ b/iOSTemplate/RatingControl.swift @@ -0,0 +1,46 @@ +// +// RatingControl.swift +// iOSTemplate +// +// Created by John Hampton on 3/3/19. +// + +import UIKit + +class RatingControl: UIStackView { + + // MARK: Initialization + override init(frame: CGRect) { + super.init(frame: frame) + setupButtons() + } + + required init(coder: NSCoder) { + super.init(coder: coder) + setupButtons() + } + + // MARK: Button Action + @objc func ratingButtonTapped(button: UIButton) { + print("Button pressed 👍") + } + + // MARK: Private Methods + private func setupButtons() { + // Create the button + let button = UIButton() + button.backgroundColor = UIColor.red + + // Add constraints + button.translatesAutoresizingMaskIntoConstraints = false + button.heightAnchor.constraint(equalToConstant: 44.0).isActive = true + button.widthAnchor.constraint(equalToConstant: 44.0).isActive = true + + // Setup the button action + button.addTarget(self, action: #selector(RatingControl.ratingButtonTapped(button:)), for: .touchUpInside) + + // Add the button to the stack + addArrangedSubview(button) + } + +}