提交 59da3538 编写于 作者: L libinbin106

selectBar

上级 28a6d5c4
......@@ -12,6 +12,8 @@
24A142FD20AEA6EA007CCF1D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 24A142FB20AEA6EA007CCF1D /* Main.storyboard */; };
24A142FF20AEA6ED007CCF1D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 24A142FE20AEA6ED007CCF1D /* Assets.xcassets */; };
24A1430220AEA6ED007CCF1D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 24A1430020AEA6ED007CCF1D /* LaunchScreen.storyboard */; };
24A1430A20AEAF08007CCF1D /* selectBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24A1430920AEAF08007CCF1D /* selectBar.swift */; };
24A1430C20AEBF4F007CCF1D /* PrefixHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24A1430B20AEBF4F007CCF1D /* PrefixHeader.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
......@@ -22,6 +24,8 @@
24A142FE20AEA6ED007CCF1D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
24A1430120AEA6ED007CCF1D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
24A1430320AEA6ED007CCF1D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
24A1430920AEAF08007CCF1D /* selectBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = selectBar.swift; sourceTree = "<group>"; };
24A1430B20AEBF4F007CCF1D /* PrefixHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrefixHeader.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -56,6 +60,8 @@
children = (
24A142F720AEA6EA007CCF1D /* AppDelegate.swift */,
24A142F920AEA6EA007CCF1D /* ViewController.swift */,
24A1430B20AEBF4F007CCF1D /* PrefixHeader.swift */,
24A1430920AEAF08007CCF1D /* selectBar.swift */,
24A142FB20AEA6EA007CCF1D /* Main.storyboard */,
24A142FE20AEA6ED007CCF1D /* Assets.xcassets */,
24A1430020AEA6ED007CCF1D /* LaunchScreen.storyboard */,
......@@ -135,8 +141,10 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
24A1430C20AEBF4F007CCF1D /* PrefixHeader.swift in Sources */,
24A142FA20AEA6EA007CCF1D /* ViewController.swift in Sources */,
24A142F820AEA6EA007CCF1D /* AppDelegate.swift in Sources */,
24A1430A20AEAF08007CCF1D /* selectBar.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="O0k-4B-o1Q">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
......@@ -9,16 +13,36 @@
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="DYZB01" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
<navigationItem key="navigationItem" id="m5V-kJ-u3o"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1076" y="133.5832083958021"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="tss-g9-Nab">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="O0k-4B-o1Q" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="RK5-8u-c2T">
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="Xg5-AC-g2V"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="nwN-7v-5V8" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="209" y="134"/>
</scene>
</scenes>
</document>
//
// PrefixHeader.swift
// DYZB01
//
// Created by temp on 2018/5/18.
// Copyright © 2018年 temp. All rights reserved.
//
import UIKit
let ScreenWidth = UIScreen.main.bounds.size.width
let ScreenHeight = UIScreen.main.bounds.size.height
class PrefixHeader: NSObject {
}
......@@ -8,11 +8,21 @@
import UIKit
class ViewController: UIViewController {
class ViewController: UIViewController , SelectBarProtocol {
func changeSelectBarItem(status: SelectBarStatus) {
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
navigationController?.navigationBar.barTintColor = UIColor.init(red: 247/255.5, green: 247/255.5, blue: 247/255.5, alpha: 1)
view.backgroundColor = UIColor.white
let bar = selectBar.init(frame: CGRect(x: 0, y: 110, width: ScreenWidth, height: 40))
bar.delegate = self
view.addSubview(bar)
}
override func didReceiveMemoryWarning() {
......
//
// selectBar.swift
// DYZB01
//
// Created by temp on 2018/5/18.
// Copyright © 2018年 temp. All rights reserved.
//
import UIKit
enum SelectBarStatus {
case SelectBarStatusRecommend
case SelectBarStatusGame
case SelectBarStatusAmuse
case SelectBarStatusFun
}
protocol SelectBarProtocol : class {
func changeSelectBarItem(status : SelectBarStatus)
}
class selectBar: UIView {
weak var delegate : SelectBarProtocol!
var recommendBtn : UIButton!
var gameBtn : UIButton!
var amuseBtn : UIButton!
var funBtn : UIButton!
var bottomLine : UIView!
override init(frame: CGRect) {
super.init(frame: frame)
recommendBtn = UIButton.init(frame: CGRect(x: 0, y: 0, width: frame.size.width / 4, height: 39))
recommendBtn.setTitle("推荐", for: .normal)
recommendBtn.addTarget(self, action: #selector(btnClick), for: .touchUpInside)
recommendBtn.setTitleColor(UIColor.orange, for: .normal)
recommendBtn.setTitleColor(UIColor.orange, for: .highlighted)
recommendBtn.titleLabel?.font = UIFont.systemFont(ofSize: 15)
addSubview(recommendBtn)
gameBtn = UIButton.init(frame: CGRect(x: frame.size.width*1 / 4, y: 0, width: frame.size.width / 4, height: 39))
gameBtn.setTitle("游戏", for: .normal)
gameBtn.addTarget(self, action: #selector(btnClick), for: .touchUpInside)
gameBtn.setTitleColor(UIColor.orange, for: .normal)
gameBtn.setTitleColor(UIColor.orange, for: .highlighted)
gameBtn.titleLabel?.font = UIFont.systemFont(ofSize: 15)
addSubview(gameBtn)
amuseBtn = UIButton.init(frame: CGRect(x: frame.size.width*2 / 4, y: 0, width: frame.size.width / 4, height: 39))
amuseBtn.setTitle("娱乐", for: .normal)
amuseBtn.addTarget(self, action: #selector(btnClick), for: .touchUpInside)
amuseBtn.setTitleColor(UIColor.orange, for: .normal)
amuseBtn.setTitleColor(UIColor.orange, for: .highlighted)
amuseBtn.titleLabel?.font = UIFont.systemFont(ofSize: 15)
addSubview(amuseBtn)
funBtn = UIButton.init(frame: CGRect(x: frame.size.width*3 / 4, y: 0, width: frame.size.width / 4, height: 39))
funBtn.setTitle("趣玩", for: .normal)
funBtn.addTarget(self, action: #selector(btnClick), for: .touchUpInside)
funBtn.setTitleColor(UIColor.orange, for: .normal)
funBtn.setTitleColor(UIColor.orange, for: .highlighted)
funBtn.titleLabel?.font = UIFont.systemFont(ofSize: 15)
addSubview(funBtn)
bottomLine = UIView.init(frame: CGRect(x: frame.size.width / 8-20, y: 39, width: 40, height: 1))
bottomLine.backgroundColor = UIColor.orange
addSubview(bottomLine)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
@objc func btnClick(sender: UIButton) {
print(sender)
recommendBtn.setTitleColor(UIColor.black, for: .normal)
gameBtn.setTitleColor(UIColor.black, for: .normal)
amuseBtn.setTitleColor(UIColor.black, for: .normal)
funBtn.setTitleColor(UIColor.black, for: .normal)
sender.setTitleColor(UIColor.orange, for: .normal)
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册