Skip to content

Instantly share code, notes, and snippets.

@christophercotton
Created August 28, 2015 14:58
Show Gist options
  • Save christophercotton/67a6f02c10d96a954c5c to your computer and use it in GitHub Desktop.
Save christophercotton/67a6f02c10d96a954c5c to your computer and use it in GitHub Desktop.
Debug versions of views which can be used to track down positioning issues
// DebugViews.swift
// Created by Christopher Cotton, no copyright
import UIKit
class DebugView: UIView {
override var bounds: CGRect {
didSet {
println("Bounds Changed: \(bounds)")
}
}
override var center: CGPoint {
didSet {
println("center Changed: \(center)")
}
}
override var frame: CGRect {
didSet {
println("frame Changed: \(frame)")
}
}
}
class DebugLabelView : UILabel {
override var bounds: CGRect {
didSet {
println("Bounds Changed: \(bounds)")
font = font.fontWithSize(bounds.height - 1)
}
}
override var center: CGPoint {
didSet {
println("center Changed: \(center)")
}
}
override var frame: CGRect {
didSet {
println("frame Changed: \(frame)")
}
}
}
class DebugTableView: UITableView {
override var bounds: CGRect {
didSet {
println("\(self) Bounds Changed: \(bounds)")
}
}
override var center: CGPoint {
didSet {
println("\(self) center Changed: \(center)")
}
}
override var contentInset: UIEdgeInsets {
didSet {
println("\(self) contentInset Changed: \(contentInset.top)")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment