Commit c0940d0f by Daniel Dahan

updated frame property access

parent 034d693f
......@@ -49,56 +49,6 @@ public class BottomTabBar: UITabBar {
}
}
/// A property that accesses the layer.frame.origin.x property.
@IBInspectable public var x: CGFloat {
get {
return layer.frame.origin.x
}
set(value) {
layer.frame.origin.x = value
}
}
/// A property that accesses the layer.frame.origin.y property.
@IBInspectable public var y: CGFloat {
get {
return layer.frame.origin.y
}
set(value) {
layer.frame.origin.y = value
}
}
/**
A property that accesses the layer.frame.size.width property.
When setting this property in conjunction with the shape property having a
value that is not .none, the height will be adjusted to maintain the correct
shape.
*/
@IBInspectable public var width: CGFloat {
get {
return layer.frame.size.width
}
set(value) {
layer.frame.size.width = value
}
}
/**
A property that accesses the layer.frame.size.height property.
When setting this property in conjunction with the shape property having a
value that is not .none, the width will be adjusted to maintain the correct
shape.
*/
@IBInspectable public var height: CGFloat {
get {
return layer.frame.size.height
}
set(value) {
layer.frame.size.height = value
}
}
/**
An initializer that initializes the object with a CGRect object.
If AutoLayout is used, it is better to initilize the instance
......
......@@ -68,34 +68,15 @@ public class Button: UIButton {
layer.backgroundColor = backgroundColor?.cgColor
}
}
/// A property that accesses the layer.frame.origin.x property.
@IBInspectable public var x: CGFloat {
get {
return layer.frame.origin.x
}
set(value) {
layer.frame.origin.x = value
}
}
/// A property that accesses the layer.frame.origin.y property.
@IBInspectable public var y: CGFloat {
get {
return layer.frame.origin.y
}
set(value) {
layer.frame.origin.y = value
}
}
/**
A property that accesses the layer.frame.size.width property.
When setting this property in conjunction with the shape property having a
value that is not .none, the height will be adjusted to maintain the correct
shape.
*/
@IBInspectable public var width: CGFloat {
@IBInspectable
public override var width: CGFloat {
get {
return layer.frame.size.width
}
......@@ -113,7 +94,8 @@ public class Button: UIButton {
value that is not .none, the width will be adjusted to maintain the correct
shape.
*/
@IBInspectable public var height: CGFloat {
@IBInspectable
public override var height: CGFloat {
get {
return layer.frame.size.height
}
......@@ -134,24 +116,6 @@ public class Button: UIButton {
}
}
/**
A property that manages the overall shape for the object. If either the
width or height property is set, the other will be automatically adjusted
to maintain the shape of the object.
*/
public var shapePreset: ShapePreset = .none {
didSet {
if .none != shapePreset {
if width < height {
frame.size.width = height
} else {
frame.size.height = width
}
layoutShadowPath()
}
}
}
/// A preset property for updated contentEdgeInsets.
public var contentEdgeInsetsPreset: EdgeInsetsPreset = .none {
didSet {
......
......@@ -176,62 +176,6 @@ public class MaterialCollectionReusableView: UICollectionReusableView {
}
}
/// A property that accesses the layer.frame.origin.x property.
@IBInspectable public var x: CGFloat {
get {
return layer.frame.origin.x
}
set(value) {
layer.frame.origin.x = value
}
}
/// A property that accesses the layer.frame.origin.y property.
@IBInspectable public var y: CGFloat {
get {
return layer.frame.origin.y
}
set(value) {
layer.frame.origin.y = value
}
}
/**
A property that accesses the layer.frame.size.width property.
When setting this property in conjunction with the shape property having a
value that is not .none, the height will be adjusted to maintain the correct
shape.
*/
@IBInspectable public var width: CGFloat {
get {
return layer.frame.size.width
}
set(value) {
layer.frame.size.width = value
if .none != shapePreset {
layer.frame.size.height = value
}
}
}
/**
A property that accesses the layer.frame.size.height property.
When setting this property in conjunction with the shape property having a
value that is not .none, the width will be adjusted to maintain the correct
shape.
*/
@IBInspectable public var height: CGFloat {
get {
return layer.frame.size.height
}
set(value) {
layer.frame.size.height = value
if .none != shapePreset {
layer.frame.size.width = value
}
}
}
/// Enables automatic shadowPath sizing.
@IBInspectable public var shadowPathAutoSizeEnabled: Bool = true {
didSet {
......@@ -242,24 +186,6 @@ public class MaterialCollectionReusableView: UICollectionReusableView {
}
/**
A property that manages the overall shape for the object. If either the
width or height property is set, the other will be automatically adjusted
to maintain the shape of the object.
*/
public var shapePreset: ShapePreset = .none {
didSet {
if .none != shapePreset {
if width < height {
frame.size.width = height
} else {
frame.size.height = width
}
layoutShadowPath()
}
}
}
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
......
......@@ -31,73 +31,33 @@
import UIKit
@IBDesignable
public class MaterialCollectionView: UICollectionView {
/// A property that accesses the layer.frame.origin.x property.
@IBInspectable public var x: CGFloat {
get {
return layer.frame.origin.x
}
set(value) {
layer.frame.origin.x = value
}
}
/// A property that accesses the layer.frame.origin.y property.
@IBInspectable public var y: CGFloat {
get {
return layer.frame.origin.y
}
set(value) {
layer.frame.origin.y = value
}
}
/// A property that accesses the layer.frame.size.width property.
@IBInspectable public var width: CGFloat {
get {
return layer.frame.size.width
}
set(value) {
layer.frame.size.width = value
}
}
/// A property that accesses the layer.frame.size.height property.
@IBInspectable public var height: CGFloat {
get {
return layer.frame.size.height
}
set(value) {
layer.frame.size.height = value
}
}
public class CollectionView: UICollectionView {
/// A preset wrapper around contentInset.
public var contentEdgeInsetsPreset: EdgeInsets {
get {
return (collectionViewLayout as? MaterialCollectionViewLayout)!.contentInset
return (collectionViewLayout as? CollectionViewLayout)!.contentInset
}
set(value) {
(collectionViewLayout as? MaterialCollectionViewLayout)!.contentInset = value
(collectionViewLayout as? CollectionViewLayout)!.contentInset = value
}
}
public override var contentInset: UIEdgeInsets {
get {
return (collectionViewLayout as? MaterialCollectionViewLayout)!.contentInset
return (collectionViewLayout as? CollectionViewLayout)!.contentInset
}
set(value) {
(collectionViewLayout as? MaterialCollectionViewLayout)!.contentInset = value
(collectionViewLayout as? CollectionViewLayout)!.contentInset = value
}
}
/// Scroll direction.
public var scrollDirection: UICollectionViewScrollDirection {
get {
return (collectionViewLayout as? MaterialCollectionViewLayout)!.scrollDirection
return (collectionViewLayout as? CollectionViewLayout)!.scrollDirection
}
set(value) {
(collectionViewLayout as? MaterialCollectionViewLayout)!.scrollDirection = value
(collectionViewLayout as? CollectionViewLayout)!.scrollDirection = value
}
}
......@@ -111,10 +71,10 @@ public class MaterialCollectionView: UICollectionView {
/// Spacing between items.
@IBInspectable public var interimSpace: InterimSpace {
get {
return (collectionViewLayout as? MaterialCollectionViewLayout)!.interimSpace
return (collectionViewLayout as? CollectionViewLayout)!.interimSpace
}
set(value) {
(collectionViewLayout as? MaterialCollectionViewLayout)!.interimSpace = value
(collectionViewLayout as? CollectionViewLayout)!.interimSpace = value
}
}
......@@ -142,7 +102,7 @@ public class MaterialCollectionView: UICollectionView {
- Parameter frame: A CGRect defining the view's frame.
*/
public init(frame: CGRect) {
super.init(frame: frame, collectionViewLayout: MaterialCollectionViewLayout())
super.init(frame: frame, collectionViewLayout: CollectionViewLayout())
prepareView()
}
......
......@@ -31,8 +31,8 @@
import UIKit
@IBDesignable
@objc(MaterialCollectionViewCell)
public class MaterialCollectionViewCell: UICollectionViewCell {
@objc(CollectionViewCell)
public class CollectionViewCell: UICollectionViewCell {
/**
A CAShapeLayer used to manage elements that would be affected by
the clipToBounds property of the backing layer. For example, this
......@@ -176,62 +176,6 @@ public class MaterialCollectionViewCell: UICollectionViewCell {
}
}
/// A property that accesses the layer.frame.origin.x property.
@IBInspectable public var x: CGFloat {
get {
return layer.frame.origin.x
}
set(value) {
layer.frame.origin.x = value
}
}
/// A property that accesses the layer.frame.origin.y property.
@IBInspectable public var y: CGFloat {
get {
return layer.frame.origin.y
}
set(value) {
layer.frame.origin.y = value
}
}
/**
A property that accesses the layer.frame.size.width property.
When setting this property in conjunction with the shape property having a
value that is not .none, the height will be adjusted to maintain the correct
shape.
*/
@IBInspectable public var width: CGFloat {
get {
return layer.frame.size.width
}
set(value) {
layer.frame.size.width = value
if .none != shape {
layer.frame.size.height = value
}
}
}
/**
A property that accesses the layer.frame.size.height property.
When setting this property in conjunction with the shape property having a
value that is not .none, the width will be adjusted to maintain the correct
shape.
*/
@IBInspectable public var height: CGFloat {
get {
return layer.frame.size.height
}
set(value) {
layer.frame.size.height = value
if .none != shape {
layer.frame.size.width = value
}
}
}
/// Enables automatic shadowPath sizing.
@IBInspectable public var shadowPathAutoSizeEnabled: Bool = true {
didSet {
......
......@@ -30,7 +30,7 @@
import UIKit
public protocol MaterialCollectionViewDataSource: UICollectionViewDataSource {
public protocol CollectionViewDataSource: UICollectionViewDataSource {
/**
Retrieves the items for the collectionView.
- Returns: An Array of Arrays of MaterialDataSourceItem objects.
......
......@@ -30,6 +30,6 @@
import UIKit
public protocol MaterialCollectionViewDelegate: MaterialDelegate, UICollectionViewDelegate {
public protocol CollectionViewDelegate: MaterialDelegate, UICollectionViewDelegate {
}
......@@ -30,7 +30,7 @@
import UIKit
public class MaterialCollectionViewLayout: UICollectionViewLayout {
public class CollectionViewLayout: UICollectionViewLayout {
/// Used to calculate the dimensions of the cells.
internal var offset: CGPoint = CGPoint.zero
......@@ -118,7 +118,7 @@ public class MaterialCollectionViewLayout: UICollectionViewLayout {
}
public override func prepare() {
if let dataSource: MaterialCollectionViewDataSource = collectionView?.dataSource as? MaterialCollectionViewDataSource {
if let dataSource: CollectionViewDataSource = collectionView?.dataSource as? CollectionViewDataSource {
prepareLayoutForItems(dataSourceItems: dataSource.items())
}
}
......
......@@ -68,6 +68,23 @@ public class Material {
}
}
/// A preset property to set the shape.
public var shapePreset: ShapePreset = .none {
didSet {
guard let v = view else {
return
}
if .none != shapePreset {
if v.width < v.height {
v.frame.size.width = v.height
} else {
v.frame.size.height = v.width
}
}
}
}
/// A preset value for Depth.
public var depthPreset: DepthPreset {
get {
......@@ -109,6 +126,70 @@ public extension UIView {
}
}
/// A property that accesses the layer.frame.origin.x property.
@IBInspectable
public var x: CGFloat {
get {
return layer.frame.origin.x
}
set(value) {
layer.frame.origin.x = value
}
}
/// A property that accesses the layer.frame.origin.y property.
@IBInspectable
public var y: CGFloat {
get {
return layer.frame.origin.y
}
set(value) {
layer.frame.origin.y = value
}
}
/// A property that accesses the layer.frame.size.width property.
@IBInspectable
public var width: CGFloat {
get {
return layer.frame.size.width
}
set(value) {
layer.frame.size.width = value
if .none != shapePreset {
layer.frame.size.height = value
}
}
}
/// A property that accesses the layer.frame.size.height property.
@IBInspectable
public var height: CGFloat {
get {
return layer.frame.size.height
}
set(value) {
layer.frame.size.height = value
if .none != shapePreset {
layer.frame.size.width = value
}
}
}
/**
A property that manages the overall shape for the object. If either the
width or height property is set, the other will be automatically adjusted
to maintain the shape of the object.
*/
public var shapePreset: ShapePreset {
get {
return material.shapePreset
}
set(value) {
material.shapePreset = value
}
}
/// A property that accesses the backing layer's shadowColor.
@IBInspectable
public var shadowColor: UIColor? {
......@@ -252,7 +333,6 @@ public extension UIView {
- Parameter animation: A CAAnimation instance.
*/
public func animate(animation: CAAnimation) {
// animation.delegate = self
if let a = animation as? CABasicAnimation {
a.fromValue = (nil == layer.presentation() ? layer : layer.presentation()!).value(forKeyPath: a.keyPath!)
}
......
......@@ -52,4 +52,4 @@ public struct MaterialDataSourceItem {
self.width = width
self.height = height
}
}
\ No newline at end of file
}
......@@ -68,56 +68,6 @@ public class MaterialTableViewCell: UITableViewCell {
}
}
/// A property that accesses the layer.frame.origin.x property.
@IBInspectable public var x: CGFloat {
get {
return layer.frame.origin.x
}
set(value) {
layer.frame.origin.x = value
}
}
/// A property that accesses the layer.frame.origin.y property.
@IBInspectable public var y: CGFloat {
get {
return layer.frame.origin.y
}
set(value) {
layer.frame.origin.y = value
}
}
/**
A property that accesses the layer.frame.size.width property.
When setting this property in conjunction with the shape property having a
value that is not .none, the height will be adjusted to maintain the correct
shape.
*/
@IBInspectable public var width: CGFloat {
get {
return layer.frame.size.width
}
set(value) {
layer.frame.size.width = value
}
}
/**
A property that accesses the layer.frame.size.height property.
When setting this property in conjunction with the shape property having a
value that is not .none, the width will be adjusted to maintain the correct
shape.
*/
@IBInspectable public var height: CGFloat {
get {
return layer.frame.size.height
}
set(value) {
layer.frame.size.height = value
}
}
/// Enables automatic shadowPath sizing.
@IBInspectable public var shadowPathAutoSizeEnabled: Bool = true {
didSet {
......
......@@ -119,56 +119,6 @@ public class NavigationBar : UINavigationBar {
}
}
/// A property that accesses the layer.frame.origin.x property.
@IBInspectable public var x: CGFloat {
get {
return layer.frame.origin.x
}
set(value) {
layer.frame.origin.x = value
}
}
/// A property that accesses the layer.frame.origin.y property.
@IBInspectable public var y: CGFloat {
get {
return layer.frame.origin.y
}
set(value) {
layer.frame.origin.y = value
}
}
/**
A property that accesses the layer.frame.size.width property.
When setting this property in conjunction with the shape property having a
value that is not .none, the height will be adjusted to maintain the correct
shape.
*/
@IBInspectable public var width: CGFloat {
get {
return layer.frame.size.width
}
set(value) {
layer.frame.size.width = value
}
}
/**
A property that accesses the layer.frame.size.height property.
When setting this property in conjunction with the shape property having a
value that is not .none, the width will be adjusted to maintain the correct
shape.
*/
@IBInspectable public var height: CGFloat {
get {
return layer.frame.size.height
}
set(value) {
layer.frame.size.height = value
}
}
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
......
......@@ -75,47 +75,7 @@ public class Switch: UIControl {
/// The bounce offset when animating.
private var bounceOffset: CGFloat = 3
/// A property that accesses the layer.frame.origin.x property.
@IBInspectable public var x: CGFloat {
get {
return layer.frame.origin.x
}
set(value) {
layer.frame.origin.x = value
}
}
/// A property that accesses the layer.frame.origin.y property.
@IBInspectable public var y: CGFloat {
get {
return layer.frame.origin.y
}
set(value) {
layer.frame.origin.y = value
}
}
/// A property that accesses the layer.frame.size.width property.
@IBInspectable public var width: CGFloat {
get {
return layer.frame.size.width
}
set(value) {
layer.frame.size.width = value
}
}
/// A property that accesses the layer.frame.size.height property.
@IBInspectable public var height: CGFloat {
get {
return layer.frame.size.height
}
set(value) {
layer.frame.size.height = value
}
}
/// An Optional delegation method.
public weak var delegate: SwitchDelegate?
......
......@@ -44,47 +44,7 @@ public class TextField: UITextField {
}
}
/// A property that accesses the layer.frame.origin.x property.
@IBInspectable public var x: CGFloat {
get {
return layer.frame.origin.x
}
set(value) {
layer.frame.origin.x = value
}
}
/// A property that accesses the layer.frame.origin.y property.
@IBInspectable public var y: CGFloat {
get {
return layer.frame.origin.y
}
set(value) {
layer.frame.origin.y = value
}
}
/// A property that accesses the layer.frame.size.width property.
@IBInspectable public var width: CGFloat {
get {
return layer.frame.size.width
}
set(value) {
layer.frame.size.width = value
}
}
/// A property that accesses the layer.frame.size.height property.
@IBInspectable public var height: CGFloat {
get {
return layer.frame.size.height
}
set(value) {
layer.frame.size.height = value
}
}
/// Reference to the divider.
/// Reference to the divider.
public private(set) lazy var divider: CAShapeLayer = CAShapeLayer()
/// Divider height.
......
......@@ -43,46 +43,6 @@ public class TextView: UITextView {
}
}
/// A property that accesses the layer.frame.origin.x property.
@IBInspectable public var x: CGFloat {
get {
return layer.frame.origin.x
}
set(value) {
layer.frame.origin.x = value
}
}
/// A property that accesses the layer.frame.origin.y property.
@IBInspectable public var y: CGFloat {
get {
return layer.frame.origin.y
}
set(value) {
layer.frame.origin.y = value
}
}
/// A property that accesses the layer.frame.size.width property.
@IBInspectable public var width: CGFloat {
get {
return layer.frame.size.width
}
set(value) {
layer.frame.size.width = value
}
}
/// A property that accesses the layer.frame.size.height property.
@IBInspectable public var height: CGFloat {
get {
return layer.frame.size.height
}
set(value) {
layer.frame.size.height = value
}
}
/// Enables automatic shadowPath sizing.
@IBInspectable public var shadowPathAutoSizeEnabled: Bool = true {
didSet {
......
......@@ -121,62 +121,6 @@ public class View: UIView {
}
}
/// A property that accesses the layer.frame.origin.x property.
@IBInspectable public var x: CGFloat {
get {
return layer.frame.origin.x
}
set(value) {
layer.frame.origin.x = value
}
}
/// A property that accesses the layer.frame.origin.y property.
@IBInspectable public var y: CGFloat {
get {
return layer.frame.origin.y
}
set(value) {
layer.frame.origin.y = value
}
}
/**
A property that accesses the layer.frame.size.width property.
When setting this property in conjunction with the shape property having a
value that is not .none, the height will be adjusted to maintain the correct
shape.
*/
@IBInspectable public var width: CGFloat {
get {
return layer.frame.size.width
}
set(value) {
layer.frame.size.width = value
if .none != shape {
layer.frame.size.height = value
}
}
}
/**
A property that accesses the layer.frame.size.height property.
When setting this property in conjunction with the shape property having a
value that is not .none, the width will be adjusted to maintain the correct
shape.
*/
@IBInspectable public var height: CGFloat {
get {
return layer.frame.size.height
}
set(value) {
layer.frame.size.height = value
if .none != shape {
layer.frame.size.width = value
}
}
}
/// Enables automatic shadowPath sizing.
@IBInspectable public var shadowPathAutoSizeEnabled: Bool = true {
didSet {
......
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