From 3ce1291747cbbcbe55ad28b163335ac034018873 Mon Sep 17 00:00:00 2001 From: FelipeNBrito Date: Tue, 7 Jun 2016 14:53:16 -0500 Subject: [PATCH] Custom alert created. Customizable: Color and Icon --- Example/SCLAlertViewExample/Main.storyboard | 11 ++++++++++- .../SCLAlertViewExample/ViewController.swift | 14 ++++++++++++++ Example/SCLAlertViewExample/custom_icon.png | Bin 0 -> 1162 bytes SCLAlertView/SCLAlertView.swift | 16 ++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 Example/SCLAlertViewExample/custom_icon.png diff --git a/Example/SCLAlertViewExample/Main.storyboard b/Example/SCLAlertViewExample/Main.storyboard index f641088..b18a645 100644 --- a/Example/SCLAlertViewExample/Main.storyboard +++ b/Example/SCLAlertViewExample/Main.storyboard @@ -1,5 +1,5 @@ - + @@ -80,6 +80,13 @@ + @@ -93,6 +100,7 @@ + @@ -100,6 +108,7 @@ + diff --git a/Example/SCLAlertViewExample/ViewController.swift b/Example/SCLAlertViewExample/ViewController.swift index fa6b283..e90f549 100644 --- a/Example/SCLAlertViewExample/ViewController.swift +++ b/Example/SCLAlertViewExample/ViewController.swift @@ -118,6 +118,20 @@ class ViewController: UIViewController { alert.showInfo("Login", subTitle: "", duration: 10) } + + @IBAction func showCustomAlert(sender: AnyObject) { + + let alert = SCLAlertView() + alert.addButton("First Button", target:self, selector:#selector(ViewController.firstButton)) + alert.addButton("Second Button") { + print("Second button tapped") + } + + let icon = UIImage(named:"custom_icon.png") + let color = UIColor.orangeColor() + + alert.showCustom("Custom Color", subTitle: "Custom color", color: color, icon: icon!) + } func firstButton() { print("First button tapped") diff --git a/Example/SCLAlertViewExample/custom_icon.png b/Example/SCLAlertViewExample/custom_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..1a2b272e2c8e65c8e279135fbcc0a7e2cecf0004 GIT binary patch literal 1162 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=3?wxlRx~p(FwPF}32_B-N5S9>fimHz`++X& zC<*clW?*DuW@TgN;N;@wE|QHZixbw6eCb zwR3QD_w)-03JH&hjEzf4OV7y6&dDz*EGaFosI0E3Z|>;nn>cCutl4wtEm*X8>9Q58 zR6Q|CcJAd)=)$4ceJ$Uxw_1pI!KY#uH^Y`B+JW}%+7?{L7 zT^vIsB;OwVZ6BP-aQx%>n`hiKxB|0E_Qy|g5fZ%{+NB|?skkU+(ru&Z@8{n=H}CnJ zv)Y&cy!)Fbew}SzY|n-6J(G`c_2joOktgi>=PDjGb)S_Iz2*M#bD@=JU#_+6`A1=2%AXPgxpjv-Q*^ zcAM5yLDutPQZpAb9sao{=ctm(-N0{b1+H6!ud3Kw_3L4FeCwm=GF9*1^=nuD{P_Cd z{L<2+Y5U8{x0v019TPI^^@Vj)PHIGJNl$&x`{nd^I|nwuew$(g)$=72dYX(s9av@a z)WPq3kn!v(J!j`L@|}DvFx}MQP{$ItOHYod$g=D^Q4}$yRBlCplZ}H{vk+T@_9mIS z6Ix7GPpte-HN_;}(B`g6ZEaB8`RXIk|C#fiYTLV z(bdP?8Y@LUrIa{sT%)zXd7bbQofD#s%to^sQYE)Ha;dIi^T-T2r2b%1kMaR$$;&D= zlS{fy7TQnJYV?z2Oqjn$L*P|xUgG3QAAfFkD2Vlp-LWgh$0{XEeX&q@UW}W%Wb0$E zUmbzEuVXvbvbs;*GO52b@|st%U3AB}Qyq`Gk3F54X&WlUXBBa SCLAlertViewResponder { + + + var red: CGFloat = 0, green: CGFloat = 0, blue: CGFloat = 0, alpha: CGFloat = 0 + + color.getRed(&red, green: &green, blue: &blue, alpha: &alpha) + + var colorAsUInt32 : UInt32 = 0 + colorAsUInt32 += UInt32(red * 255.0) << 16 + UInt32(green * 255.0) << 8 + UInt32(blue * 255.0) + + let colorAsUInt = UInt(colorAsUInt32) + + return showTitle(title, subTitle: subTitle, duration: duration, completeText:closeButtonTitle, style: .Success, colorStyle: colorAsUInt, colorTextButton: colorTextButton, circleIconImage: icon, animationStyle: animationStyle) + } + // showSuccess(view, title, subTitle) public func showSuccess(title: String, subTitle: String, closeButtonTitle:String?=nil, duration:NSTimeInterval=0.0, colorStyle: UInt=SCLAlertViewStyle.Success.defaultColorInt, colorTextButton: UInt=0xFFFFFF, circleIconImage: UIImage? = nil, animationStyle: SCLAnimationStyle = .TopToBottom) -> SCLAlertViewResponder { return showTitle(title, subTitle: subTitle, duration: duration, completeText:closeButtonTitle, style: .Success, colorStyle: colorStyle, colorTextButton: colorTextButton, circleIconImage: circleIconImage, animationStyle: animationStyle)