Beginning work on header view

This commit is contained in:
Charles Magahern
2015-12-30 18:47:13 -08:00
parent 00fcca6893
commit 29dec42b20
21 changed files with 592 additions and 43 deletions

View File

@@ -0,0 +1,90 @@
//
// HeaderView.swift
// XIONControlPanel
//
// Created by Charles Magahern on 12/30/15.
// Copyright © 2015 XION. All rights reserved.
//
import Darwin
import Foundation
import UIKit
class HeaderView: UIView {
private var _xionLogoView: XIONLogoView = XIONLogoView()
private var _xionTitleLabel: UILabel = UILabel()
private var _xionJapaneseLabel: UILabel = UILabel()
override init(frame: CGRect)
{
super.init(frame: frame)
self.backgroundColor = UIColor.blackColor()
self.addSubview(_xionLogoView)
_xionTitleLabel.font = UIFont(name: "Orbitron-Medium", size: 16.0)
_xionTitleLabel.text = "XION arcade system control panel"
_xionTitleLabel.textColor = UIColor.whiteColor()
self.addSubview(_xionTitleLabel)
_xionJapaneseLabel.font = UIFont(name: "Orbitron-Medium", size: 12.0)
_xionJapaneseLabel.text = "ザイーオンゲームセンターのシステム制御プログラム"
_xionJapaneseLabel.textColor = UIColor.whiteColor()
self.addSubview(_xionJapaneseLabel)
}
required init?(coder aDecoder: NSCoder)
{
fatalError("unsupported")
}
override func layoutSubviews()
{
super.layoutSubviews()
let bounds = self.bounds
let hpadding = CGFloat(10.0)
let logoDimensions = rint(bounds.size.height / 1.2)
let logoFrame = CGRect(
x: hpadding,
y: rint(bounds.size.height / 2.0 - logoDimensions / 2.0),
width: logoDimensions,
height: logoDimensions
)
_xionLogoView.frame = logoFrame
let titleJPVerticalMargin: CGFloat = 5.0
let titleLabelSize = _xionTitleLabel.sizeThatFits(bounds.size)
let jpLabelSize = _xionJapaneseLabel.sizeThatFits(bounds.size)
let totalLabelsHeight = titleLabelSize.height + titleJPVerticalMargin + jpLabelSize.height
let titleFrame = CGRect(
x: CGRectGetMaxX(logoFrame) + hpadding * 2.0,
y: rint(bounds.size.height / 2.0 - totalLabelsHeight / 2.0),
width: titleLabelSize.width,
height: titleLabelSize.height
)
_xionTitleLabel.frame = titleFrame
let jpTitleFrame = CGRect(
x: titleFrame.origin.x,
y: CGRectGetMaxY(titleFrame) + titleJPVerticalMargin,
width: jpLabelSize.width,
height: jpLabelSize.height + 2.0
)
_xionJapaneseLabel.frame = jpTitleFrame
}
// MARK: API
func beginAnimating()
{
_xionLogoView.beginAnimating()
}
func stopAnimating()
{
_xionLogoView.stopAnimating()
}
}

View File

@@ -0,0 +1,78 @@
//
// XIONLogoView.swift
// XIONControlPanel
//
// Created by Charles Magahern on 12/30/15.
// Copyright © 2015 XION. All rights reserved.
//
import UIKit
class XIONLogoView: UIView {
private var _xionLogoImageView: UIImageView = UIImageView()
private var _logoInnerRingImageView: UIImageView = UIImageView()
private var _logoOuterRingImageView: UIImageView = UIImageView()
override init(frame: CGRect)
{
super.init(frame: frame)
self.backgroundColor = UIColor.blackColor()
_xionLogoImageView.image = UIImage(named: "XIONLogoWithRing")
_xionLogoImageView.contentMode = .ScaleAspectFit
_logoInnerRingImageView.image = UIImage(named: "XIONLogoInnerRing")
_logoInnerRingImageView.contentMode = .ScaleAspectFit
_logoOuterRingImageView.image = UIImage(named: "XIONLogoOuterRing")
_logoOuterRingImageView.contentMode = .ScaleAspectFit
self.addSubview(_logoOuterRingImageView)
self.addSubview(_logoInnerRingImageView)
self.addSubview(_xionLogoImageView)
}
required init?(coder aDecoder: NSCoder)
{
fatalError("unsupported")
}
override func layoutSubviews()
{
super.layoutSubviews()
let bounds = self.bounds
_xionLogoImageView.frame = bounds
_logoInnerRingImageView.frame = bounds
_logoOuterRingImageView.frame = bounds
}
// MARK: API
func beginAnimating()
{
let duration: NSTimeInterval = 20.0
let clockwiseAnim = CABasicAnimation(keyPath: "transform.rotation")
clockwiseAnim.fromValue = 0.0
clockwiseAnim.toValue = 2.0 * π
clockwiseAnim.duration = duration
clockwiseAnim.repeatCount = Float.infinity
let counterClockwiseAnim = CABasicAnimation(keyPath: "transform.rotation")
counterClockwiseAnim.fromValue = 2.0 * π
counterClockwiseAnim.toValue = 0.0
counterClockwiseAnim.duration = duration
counterClockwiseAnim.repeatCount = Float.infinity
_logoInnerRingImageView.layer.addAnimation(clockwiseAnim, forKey: "")
_logoOuterRingImageView.layer.addAnimation(counterClockwiseAnim, forKey: "")
}
func stopAnimating()
{
_logoInnerRingImageView.layer.removeAllAnimations()
_logoOuterRingImageView.layer.removeAllAnimations()
}
}