From eafb6c26b4c5d3a4313ca7bfd0cf992fedc6230a Mon Sep 17 00:00:00 2001 From: Cem Olcay Date: Thu, 8 Jan 2015 10:43:06 +0200 Subject: [PATCH] ScreenWidth & ScreenHeight updated with orientation Orientation added organized code --- .../UserInterfaceState.xcuserstate | Bin 28084 -> 30062 bytes CEMKit-Swift/CEMKit.swift | 169 ++++++++++-------- 2 files changed, 96 insertions(+), 73 deletions(-) diff --git a/CEMKit-Swift.xcodeproj/project.xcworkspace/xcuserdata/cem.xcuserdatad/UserInterfaceState.xcuserstate b/CEMKit-Swift.xcodeproj/project.xcworkspace/xcuserdata/cem.xcuserdatad/UserInterfaceState.xcuserstate index 161f472fccf0e664c7fcdb2b2c73f43eb44632e3..64b0b4b12f3f0effd7e9c1f81ceacfa23cf7201c 100644 GIT binary patch delta 8395 zcmeHLd0bP+x1Z%EghVUu;0g#XgaopX4T2ylD1s=so8=}qfrL$2+%%OqK z)@l{4Kdsia`m?QCwOXrfwXI#$+N!l$t;?GbwE8~3_x^r=Jovzwd(NDhGiT0x&zaeE z1^#vuE@*`pF~Y*IZm?)!S~p(?$OiqvAm9RSkPixg2Y5jtC;_8E87K$i!2~c7_`qE7 z7MKU#2J^uJun;T(?|>Dc7Hk5W!FymE*a_;uL2w8h21meAa14A5j)N26Joo}!02jfR z;1c)>Tn4{@8{j6m1%3s$!CmktcmN)PzZTxw=0irK3#LALXFIXb2jCY=}bzs0fWhW6)SM8BIa6(H!(9nv3S6DpZYXP%T=I zHlU4Y6WWaSpnd2=v>zQnN6|@i3Y|q4&_#3^T|rmT56E{N-9dNJJ@f~6p z#WEa%Lva{xgWKYEI0{GO&Nvn;unOz30h@6z+#9Fk{x}B@z(epz%wZRH;}TqoC*nzX zGM<8ccs^c$7ve=&z>Dz`yb`a%)wl+~i?`zUa2?)@58{ve;!p7zd=+2A-{J4^5BNI% z5&wbj<3I5O{1E?zAK_>CIRhAmkuYyCO_)|p8>TJOkqKuam}sUO6T`@vSVqC5F+GLv zQ1dQ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) + + if let ok = okAction { + a.addAction(UIAlertAction(title: "OK", style: .Default, handler: ok)) + a.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: cancelAction)) + } else { + a.addAction(UIAlertAction(title: "OK", style: .Cancel, handler: cancelAction)) + } + + return a +} + + + +// MARK: - UIBarButtonItem + +func barButtonItem (imageName: String, + action: (AnyObject)->()) -> UIBarButtonItem { + let button = BlockButton (frame: CGRect(x: 0, y: 0, width: 20, height: 20)) + button.setImage(UIImage(named: imageName), forState: .Normal) + button.actionBlock = action + + return UIBarButtonItem (customView: button) +} + +func barButtonItem (title: String, + color: UIColor, + action: (AnyObject)->()) -> UIBarButtonItem { + let button = BlockButton (frame: CGRect(x: 0, y: 0, width: 20, height: 20)) + button.setTitle(title, forState: .Normal) + button.setTitleColor(color, forState: .Normal) + button.actionBlock = action + button.sizeToFit() + + return UIBarButtonItem (customView: button) +} + + + +// MARK: - CGSize + +func + (left: CGSize, right: CGSize) -> CGSize { + return CGSize (width: left.width + right.width, height: left.height + right.height) +} + +func - (left: CGSize, right: CGSize) -> CGSize { + return CGSize (width: left.width - right.width, height: left.width - right.width) +} + + + // MARK: - CGPoint func + (left: CGPoint, right: CGPoint) -> CGPoint { @@ -641,39 +736,8 @@ extension CGPoint: StringLiteralConvertible { -// MARK: - CGSize - -func + (left: CGSize, right: CGSize) -> CGSize { - return CGSize (width: left.width + right.width, height: left.height + right.height) -} - -func - (left: CGSize, right: CGSize) -> CGSize { - return CGSize (width: left.width - right.width, height: left.width - right.width) -} - - - // MARK: - CGFloat -var ScreenWidth: CGFloat { - get { - return UIScreen.mainScreen().bounds.size.width - } -} - -var ScreenHeight: CGFloat { - get { - return UIScreen.mainScreen().bounds.size.height - } -} - -var StatusBarHeight: CGFloat { - get { - return UIApplication.sharedApplication().statusBarFrame.height - } -} - - func degreesToRadians (angle: CGFloat) -> CGFloat { return (CGFloat (M_PI) * angle) / 180.0 } @@ -694,49 +758,8 @@ func convertNormalizedValue (value: CGFloat, -// MARK: - UIAlertController - -func alert (title: String, - message: String, - cancelAction: ((UIAlertAction!)->Void)? = nil, - okAction: ((UIAlertAction!)->Void)? = nil) -> UIAlertController { - let a = UIAlertController (title: title, message: message, preferredStyle: .Alert) - - if let ok = okAction { - a.addAction(UIAlertAction(title: "OK", style: .Default, handler: ok)) - a.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: cancelAction)) - } else { - a.addAction(UIAlertAction(title: "OK", style: .Cancel, handler: cancelAction)) - } - - return a -} - - - -// MARK: - UIBarButtonItem - -func barButtonItem (imageName: String, - action: (AnyObject)->()) -> UIBarButtonItem { - let button = BlockButton (frame: CGRect(x: 0, y: 0, width: 20, height: 20)) - button.setImage(UIImage(named: imageName), forState: .Normal) - button.actionBlock = action - - return UIBarButtonItem (customView: button) -} - -func barButtonItem (title: String, - color: UIColor, - action: (AnyObject)->()) -> UIBarButtonItem { - let button = BlockButton (frame: CGRect(x: 0, y: 0, width: 20, height: 20)) - button.setTitle(title, forState: .Normal) - button.setTitleColor(color, forState: .Normal) - button.actionBlock = action - button.sizeToFit() - - return UIBarButtonItem (customView: button) -} +// MARK: - Block Classes // MARK: - BlockButton