Commit c410b704 authored by Andres Käver's avatar Andres Käver

custum ui

parent 8fe16202
......@@ -13,6 +13,7 @@
A9A46219255ECC8700F806DA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A9A46217255ECC8700F806DA /* Main.storyboard */; };
A9A4621B255ECC8800F806DA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A9A4621A255ECC8800F806DA /* Assets.xcassets */; };
A9A4621E255ECC8800F806DA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A9A4621C255ECC8800F806DA /* LaunchScreen.storyboard */; };
A9A46227255EE20200F806DA /* UITileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9A46226255EE20200F806DA /* UITileView.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
......@@ -24,6 +25,7 @@
A9A4621A255ECC8800F806DA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
A9A4621D255ECC8800F806DA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
A9A4621F255ECC8800F806DA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
A9A46226255EE20200F806DA /* UITileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITileView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -63,6 +65,7 @@
A9A4621A255ECC8800F806DA /* Assets.xcassets */,
A9A4621C255ECC8800F806DA /* LaunchScreen.storyboard */,
A9A4621F255ECC8800F806DA /* Info.plist */,
A9A46226255EE20200F806DA /* UITileView.swift */,
);
path = "TicTacToe2020-2";
sourceTree = "<group>";
......@@ -139,6 +142,7 @@
files = (
A9A46216255ECC8700F806DA /* ViewController.swift in Sources */,
A9A46212255ECC8700F806DA /* AppDelegate.swift in Sources */,
A9A46227255EE20200F806DA /* UITileView.swift in Sources */,
A9A46214255ECC8700F806DA /* SceneDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
......
......@@ -84,6 +84,36 @@
</objects>
<point key="canvasLocation" x="140.57971014492756" y="56.919642857142854"/>
</scene>
<!--View Controller-->
<scene sceneID="QaI-mC-G1J">
<objects>
<viewController id="8cQ-hC-Owe" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="SJa-7W-xot">
<rect key="frame" x="0.0" y="0.0" width="390" height="844"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="p99-7v-bZy" customClass="UITileView" customModule="TicTacToe2020_2" customModuleProvider="target">
<rect key="frame" x="75" y="309" width="136" height="164"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="colorCross">
<color key="value" systemColor="systemPinkColor"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="showElement">
<integer key="value" value="2"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="LEP-JK-ekg"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="ZPt-B9-Caq" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1078.4615384615383" y="76.777251184834114"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
......@@ -92,6 +122,9 @@
<systemColor name="systemOrangeColor">
<color red="1" green="0.58431372549019611" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemPinkColor">
<color red="1" green="0.17647058823529413" blue="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemYellowColor">
<color red="1" green="0.80000000000000004" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
......
......@@ -7,14 +7,70 @@
import UIKit
// make it previewable in storyboard editor
@IBDesignable
class UITileView: UIView {
/*
// make the property modifiable via the storyboard editor
@IBInspectable
var showElement: Int = 1 { didSet { setNeedsDisplay() } } // 0 - empty, 1 - X, 2 - O
@IBInspectable
var colorCross: UIColor = UIColor.blue { didSet { setNeedsDisplay() } }
@IBInspectable
var colorCircle: UIColor = UIColor.red { didSet { setNeedsDisplay() } }
// catch the resizing, and redraw
override var bounds: CGRect {
didSet {
setNeedsDisplay()
}
}
// Only override draw() if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func draw(_ rect: CGRect) {
// Drawing code
switch (showElement) {
case 1 :
colorCross.set()
let cross = pathForCross()
cross.stroke()
case 2:
colorCircle.set()
let circle = pathForCircle()
circle.stroke()
default:
break
}
}
*/
func pathForCircle() -> UIBezierPath {
let path = UIBezierPath(arcCenter: CGPoint(x: bounds.midX, y: bounds.midY), radius: CGFloat(min(bounds.midX, bounds.midY) * 0.8), startAngle: CGFloat(0), endAngle: CGFloat(2 * Double.pi), clockwise: true)
path.lineWidth = CGFloat(10)
return path
}
func pathForCross() -> UIBezierPath {
let path = UIBezierPath()
path.lineWidth = CGFloat(10)
path.move(to: CGPoint(x: 0, y: 0))
path.addLine(to: CGPoint(x: bounds.maxX, y: bounds.maxY))
path.move(to: CGPoint(x: bounds.maxX, y: 0))
path.addLine(to: CGPoint(x: 0, y: bounds.maxY))
print("maxx \(bounds.maxX) maxy \(bounds.maxY)")
return path
}
}
......@@ -34,6 +34,7 @@ class ViewController: UIViewController {
for subView in GameBoard.arrangedSubviews {
if let stack = subView as? UIStackView {
/*
let button = UIButton()
button.backgroundColor = #colorLiteral(red: 0.1764705926, green: 0.4980392158, blue: 0.7568627596, alpha: 1)
button.setTitle("\(buttonCounter)", for: UIControl.State.normal)
......@@ -42,11 +43,23 @@ class ViewController: UIViewController {
button.addTarget(self, action: #selector(buttonClicked(_:)), for: UIControl.Event.touchUpInside)
stack.addArrangedSubview(button)
*/
buttonCounter += 1
let gameButton = UITileView()
gameButton.tag = buttonCounter
gameButton.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleTap(_:))))
stack.addArrangedSubview(gameButton)
}
}
}
@objc func handleTap(_ sender: UITapGestureRecognizer? = nil) {
print("\(String(describing: sender?.view?.tag))")
}
@IBAction func RowMinusClicked(_ sender: UIButton) {
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment