{"id":7822,"date":"2015-10-30T07:36:56","date_gmt":"2015-10-30T07:36:56","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/10\/30\/swift-1-2-sweetalert-syntax-update-open-source-projects-t4t5-sweetalert\/"},"modified":"2015-10-30T07:36:56","modified_gmt":"2015-10-30T07:36:56","slug":"swift-1-2-sweetalert-syntax-update-open-source-projects-t4t5-sweetalert","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/10\/30\/swift-1-2-sweetalert-syntax-update-open-source-projects-t4t5-sweetalert\/","title":{"rendered":"Swift 1.2 SweetAlert Syntax Update-open source projects t4t5\/sweetalert"},"content":{"rendered":"<p>Can someone help me update the syntax to SweetAlert. It will then be available for everyone to use.<\/p>\n<pre><code>\/\/  SweetAlert.swift\n\/\/  SweetAlert\n\/\/\n\/\/  Created by Codester on 11\/3\/14.\n\/\/  Copyright (c) 2014 Codester. All rights reserved.\n\/\/\n\nimport Foundation\nimport UIKit\nimport QuartzCore\n\nenum AlertStyle {\n   case Success,Error,Warning,None\n   case CustomImag(imageFile:String)\n}\n\nclass SweetAlert: UIViewController {\n\nlet kBakcgroundTansperancy: CGFloat = 0.7\nlet kHeightMargin: CGFloat = 10.0\nlet KTopMargin: CGFloat = 20.0\nlet kWidthMargin: CGFloat = 10.0\nlet kAnimatedViewHeight: CGFloat = 70.0\nlet kMaxHeight: CGFloat = 500.0\nvar kContentWidth: CGFloat = 300.0\nlet kButtonHeight: CGFloat = 35.0\nvar textViewHeight: CGFloat = 90.0\nlet kTitleHeight:CGFloat = 30.0\nvar strongSelf:SweetAlert?\nvar contentView = UIView()\nvar titleLabel: UILabel = UILabel()\nvar buttons: [UIButton] = []\nvar animatedView: AnimatableView?\nvar imageView:UIImageView?\nvar subTitleTextView = UITextView()\nvar userAction:((isOtherButton: Bool) -&gt; Void)? = nil\nlet kFont = \"Helvetica\"\n\n\nfunc setupContentView() {\n    \/\/Retaining itself strongly so can exist without strong refrence\n    strongSelf = self\n    self.view.frame = UIScreen().bounds\n    self.view.autoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth\n    self.view.backgroundColor = UIColor(red:0, green:0, blue:0, alpha:kBakcgroundTansperancy)\n    self.view.addSubview(contentView)\n    contentView.backgroundColor = UIColor(white: 1.0, alpha: 1.0)\n    contentView.layer.cornerRadius = 5.0\n    contentView.layer.masksToBounds = true\n    contentView.layer.borderWidth = 0.5\n    contentView.addSubview(titleLabel)\n    contentView.addSubview(subTitleTextView)\n    contentView.backgroundColor = UIColorFromRGB(0xFFFFFF)\n    contentView.layer.borderColor = UIColorFromRGB(0xCCCCCC).CGColor\n    view.addSubview(contentView)\n}\n\nfunc setupTitleLabel() {\n    titleLabel.text = \"\"\n    titleLabel.numberOfLines = 1\n    titleLabel.textAlignment = .Center\n    titleLabel.font = UIFont(name: kFont, size:25)\n    titleLabel.textColor = UIColorFromRGB(0x575757)\n}\n\nfunc setupSubtitleTextView() {\n    subTitleTextView.text = \"\"\n    subTitleTextView.textAlignment = .Center\n    subTitleTextView.font = UIFont(name: kFont, size:16)\n    subTitleTextView.textColor = UIColorFromRGB(0x797979)\n    subTitleTextView.editable = false\n}\n\nfunc resizeAndRelayout() {\n\n    var mainScreenBounds = UIScreen.mainScreen().bounds\n    self.view.frame.size = mainScreenBounds.size\n    var x: CGFloat = kWidthMargin\n    var y: CGFloat = KTopMargin\n    var width: CGFloat = kContentWidth - (kWidthMargin*2)\n\n    if animatedView != nil {\n         animatedView!.frame = CGRect(x: (kContentWidth - kAnimatedViewHeight) \/ 2.0, y: y, width: kAnimatedViewHeight, height: kAnimatedViewHeight)\n        contentView.addSubview(animatedView!)\n        y += kAnimatedViewHeight + kHeightMargin\n    }\n\n    if imageView != nil {\n        imageView!.frame = CGRect(x: (kContentWidth - kAnimatedViewHeight) \/ 2.0, y: y, width: kAnimatedViewHeight, height: kAnimatedViewHeight)\n        contentView.addSubview(imageView!)\n        y += imageView!.frame.size.height + kHeightMargin\n    }\n\n\n    \/\/ Title\n    if self.titleLabel.text != nil {\n        titleLabel.frame = CGRect(x: x, y: y, width: width, height: kTitleHeight)\n        contentView.addSubview(titleLabel)\n        y += kTitleHeight + kHeightMargin\n    }\n\n    \/\/ Subtitle\n    if self.subTitleTextView.text.isEmpty == false {\n        let subtitleString = subTitleTextView.text! as NSString\n        let rect = subtitleString.boundingRectWithSize(CGSize(width: width, height:0.0), options: NSStringDrawingOptions.UsesLineFragmentOrigin, attributes:[NSFontAttributeName:subTitleTextView.font], context:nil)\n        textViewHeight = ceil(rect.size.height) + 10.0\n        subTitleTextView.frame = CGRect(x: x, y: y, width: width, height: textViewHeight)\n        contentView.addSubview(subTitleTextView)\n        y += textViewHeight + kHeightMargin\n    }\n\n    var buttonRect:[CGRect] = []\n    for button in buttons {\n        let string = button.titleForState(UIControlState.Normal)! as NSString\n        buttonRect.append(string.boundingRectWithSize(CGSize(width: width, height:0.0), options: NSStringDrawingOptions.UsesLineFragmentOrigin, attributes:[NSFontAttributeName:button.titleLabel!.font], context:nil))\n    }\n\n    var totalWidth: CGFloat = 0.0\n    if buttons.count == 2 {\n        totalWidth = buttonRect[0].size.width + buttonRect[1].size.width + kWidthMargin + 40.0\n    }\n    else{\n        totalWidth = buttonRect[0].size.width + 20.0\n    }\n    y += kHeightMargin\n    var buttonX = (kContentWidth - totalWidth ) \/ 2.0\n    for var i = 0; i &lt;  buttons.count; i++ {\n\n            buttons[i].frame = CGRect(x: buttonX, y: y, width: buttonRect[i].size.width + 20.0, height: buttonRect[i].size.height + 10.0)\n            buttonX = buttons[i].frame.origin.x + kWidthMargin + buttonRect[i].size.width + 20.0\n            buttons[i].layer.cornerRadius = 5.0\n            self.contentView.addSubview(buttons[i])\n            buttons[i].addTarget(self, action: \"pressed:\", forControlEvents: UIControlEvents.TouchUpInside)\n\n    }\n    y += kHeightMargin + buttonRect[0].size.height + 10.0\n\n    contentView.frame = CGRect(x: (mainScreenBounds.size.width - kContentWidth) \/ 2.0, y: (mainScreenBounds.size.height - y) \/ 2.0, width: kContentWidth, height: y)\n    contentView.clipsToBounds = true\n}\n\nfunc pressed(sender: UIButton!) {\n    self.closeAlert(sender.tag)\n}\n\n\noverride func viewWillLayoutSubviews() {\n    super.viewWillLayoutSubviews()\n    var sz = UIScreen.mainScreen().bounds.size\n    let sver = UIDevice.currentDevice().systemVersion as NSString\n    let ver = sver.floatValue\n    if ver &lt; 8.0 {\n        \/\/ iOS versions before 7.0 did not switch the width and height on device roration\n        if UIInterfaceOrientationIsLandscape(UIApplication.sharedApplication().statusBarOrientation) {\n            let ssz = sz\n            sz = CGSize(width:ssz.height, height:ssz.width)\n        }\n    }\n    self.resizeAndRelayout()\n}\n\n\nfunc buttonTapped(btn:UIButton) {\n\n}\n\nrequired init(coder aDecoder: NSCoder) {\n    fatalError(\"init(coder:) has not been implemented\")\n}\n\noverride init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {\n    super.init(nibName:nibNameOrNil, bundle:nibBundleOrNil)\n}\n\nfunc closeAlert(buttonIndex:Int){\n\n    if userAction !=  nil {\n\n        var isOtherButton = buttonIndex == 0 ? true: false\n        SweetAlertContext.shouldNotAnimate = true\n        userAction!(isOtherButton: isOtherButton)\n        SweetAlertContext.shouldNotAnimate = false\n    }\n\n    UIView.animateWithDuration(0.5, delay: 0.0, options: UIViewAnimationOptions.CurveEaseOut, animations: { () -&gt; Void in\n        self.view.alpha = 0.0\n    }) { (Bool) -&gt; Void in\n        self.view.removeFromSuperview()\n        self.cleanUpAlert()\n\n        \/\/Releasing strong refrence of itself.\n        self.strongSelf = nil\n    }\n}\n\nfunc cleanUpAlert() {\n\n    if self.animatedView != nil {\n        self.animatedView!.removeFromSuperview()\n        self.animatedView = nil\n    }\n    self.contentView.removeFromSuperview()\n    self.contentView = UIView()\n}\n\nfunc showAlert(title: String) -&gt; SweetAlert {\n    self.showAlert(title, subTitle: nil, style: .None)\n    return self\n}\n\nfunc showAlert(title: String, subTitle: String?, style: AlertStyle) -&gt; SweetAlert {\n    self.showAlert(title, subTitle: subTitle, style: style, buttonTitle: \"OK\")\n    return self\n\n}\n\nfunc showAlert(title: String, subTitle: String?, style: AlertStyle,buttonTitle: String, action: ((isOtherButton: Bool) -&gt; Void)? = nil) -&gt; SweetAlert {\n    self.showAlert(title, subTitle: subTitle, style: style, buttonTitle: buttonTitle,buttonColor: UIColorFromRGB(0xAEDEF4))\n    userAction = action\n    return self\n\n\n}\n\nfunc showAlert(title: String, subTitle: String?, style: AlertStyle,buttonTitle: String,buttonColor: UIColor,action: ((isOtherButton: Bool) -&gt; Void)? = nil) -&gt; SweetAlert {\n    self.showAlert(title, subTitle: subTitle, style: style, buttonTitle: buttonTitle,buttonColor: buttonColor,otherButtonTitle:\n        nil)\n    userAction = action\n    return self\n\n}\n\nfunc showAlert(title: String, subTitle: String?, style: AlertStyle,buttonTitle: String,buttonColor: UIColor,otherButtonTitle:\n    String?, action: ((isOtherButton: Bool) -&gt; Void)? = nil) -&gt; SweetAlert {\n        self.showAlert(title, subTitle: subTitle, style: style, buttonTitle: buttonTitle,buttonColor: buttonColor,otherButtonTitle:\n            otherButtonTitle,otherButtonColor: UIColor.redColor())\n        userAction = action\n        return self\n\n}\n\nfunc showAlert(title: String, subTitle: String?, style: AlertStyle,buttonTitle: String,buttonColor: UIColor,otherButtonTitle:\n    String?, otherButtonColor: UIColor?,action: ((isOtherButton: Bool) -&gt; Void)? = nil) {\n        userAction = action\n        let window = UIApplication.sharedApplication().keyWindow?.subviews.first as! UIView\n        window.addSubview(view)\n        view.frame = window.bounds\n        self.setupContentView()\n        self.setupTitleLabel()\n        self.setupSubtitleTextView()\n\n\n        switch style {\n\n        case .Success:\n            self.animatedView = SuccessAnimatedView()\n\n        case .Error:\n            self.animatedView = CancelAnimatedView()\n\n        case .Warning:\n            self.animatedView = InfoAnimatedView()\n\n        case let .CustomImag(imageFile):\n            if let image = UIImage(named: imageFile) {\n                self.imageView = UIImageView(image: image)\n            }\n        case .None:\n            self.animatedView = nil\n        }\n\n        self.titleLabel.text = title\n\n        if subTitle != nil {\n            self.subTitleTextView.text = subTitle\n        }\n\n        buttons = []\n        if buttonTitle.isEmpty == false {\n\n            var button: UIButton = UIButton.buttonWithType(UIButtonType.Custom)as! UIButton\n            button.setTitle(buttonTitle, forState: UIControlState.Normal)\n            button.backgroundColor = buttonColor\n            button.userInteractionEnabled = true\n            button.tag = 0\n            buttons.append(button)\n\n\n        }\n\n        if otherButtonTitle != nil &amp;&amp; otherButtonTitle!.isEmpty == false {\n\n            var button: UIButton = UIButton.buttonWithType(UIButtonType.Custom)as! UIButton\n            button.setTitle(otherButtonTitle, forState: UIControlState.Normal)\n            button.backgroundColor = otherButtonColor\n            button.addTarget(self, action: \"pressed:\", forControlEvents: UIControlEvents.TouchUpInside)\n            button.tag = 1\n            buttons.append(button)\n        }\n\n        resizeAndRelayout()\n\n        if SweetAlertContext.shouldNotAnimate == true {\n\n            \/\/Do not animate Alert\n            if self.animatedView != nil {\n                self.animatedView!.animate()\n            }\n\n        }\n        else {\n\n            animateAlert()\n        }\n}\n\nfunc animateAlert() {\n\n    view.alpha = 0;\n    UIView.animateWithDuration(0.1, animations: { () -&gt; Void in\n        self.view.alpha = 1.0;\n    })\n\n    var previousTransform = self.contentView.transform\n    self.contentView.layer.transform = CATransform3DMakeScale(0.9, 0.9, 0.0);\n\n    UIView.animateWithDuration(0.2, animations: { () -&gt; Void in\n\n        self.contentView.layer.transform = CATransform3DMakeScale(1.1, 1.1, 0.0);\n\n        }) { (Bool) -&gt; Void in\n\n            UIView.animateWithDuration(0.1, animations: { () -&gt; Void in\n\n                self.contentView.layer.transform = CATransform3DMakeScale(0.9, 0.9, 0.0);\n\n                }) { (Bool) -&gt; Void in\n\n                    UIView.animateWithDuration(0.1, animations: { () -&gt; Void in\n\n                        self.contentView.layer.transform = CATransform3DMakeScale(1.0, 1.0, 0.0);\n                        if self.animatedView != nil {\n                            self.animatedView!.animate()\n                        }\n\n                        }) { (Bool) -&gt; Void in\n\n                            self.contentView.transform = previousTransform\n                    }\n            }\n    }\n}\n\nprivate struct SweetAlertContext {\n    static var shouldNotAnimate = false\n}\n }\n\n\/\/ MARK: -\n\n\/\/ MARK: Animatable Views\n\nclass AnimatableView: UIView {\n\nfunc animate(){\n    println(\"Should overide by subclasss\")\n  }\n }\n\nclass CancelAnimatedView: AnimatableView {\n\nvar circleLayer = CAShapeLayer()\nvar crossPathLayer = CAShapeLayer()\n\noverride required init(frame: CGRect) {\n    super.init(frame: frame)\n    setupLayers()\n    var t = CATransform3DIdentity;\n    t.m34 = 1.0 \/ -500.0;\n    t = CATransform3DRotate(t, CGFloat(90.0 * M_PI \/ 180.0), 1, 0, 0);\n    circleLayer.transform = t\n    crossPathLayer.opacity = 0.0\n\n}\n\noverride func layoutSubviews() {\n    setupLayers()\n}\n\nrequired  init(coder aDecoder: NSCoder) {\n    fatalError(\"init(coder:) has not been implemented\")\n}\n\n var outlineCircle: CGPath  {\n    var path = UIBezierPath()\n    let startAngle: CGFloat = CGFloat((0) \/ 180.0 * M_PI)  \/\/0\n    let endAngle: CGFloat = CGFloat((360) \/ 180.0 * M_PI)   \/\/360\n    path.addArcWithCenter(CGPointMake(self.frame.size.width\/2.0, self.frame.size.width\/2.0), radius: self.frame.size.width\/2.0, startAngle: startAngle, endAngle: endAngle, clockwise: false)\n\n    return path.CGPath\n    }\n\nvar crossPath: CGPath  {\n    var path = UIBezierPath()\n    var factor:CGFloat = self.frame.size.width \/ 5.0\n    path.moveToPoint(CGPoint(x: self.frame.size.height\/2.0-factor,y: self.frame.size.height\/2.0-factor))\n    path.addLineToPoint(CGPoint(x: self.frame.size.height\/2.0+factor,y: self.frame.size.height\/2.0+factor))\n    path.moveToPoint(CGPoint(x: self.frame.size.height\/2.0+factor,y: self.frame.size.height\/2.0-factor))\n    path.addLineToPoint(CGPoint(x: self.frame.size.height\/2.0-factor,y: self.frame.size.height\/2.0+factor))\n\n    return path.CGPath\n}\n\nfunc setupLayers() {\n\n    circleLayer.path = outlineCircle\n    circleLayer.fillColor = UIColor.clearColor().CGColor;\n    circleLayer.strokeColor = UIColorFromRGB(0xF27474).CGColor;\n    circleLayer.lineCap = kCALineCapRound\n    circleLayer.lineWidth = 4;\n    circleLayer.frame = CGRect(x: 0, y: 0, width: self.frame.size.width, height: self.frame.size.height)\n    circleLayer.position = CGPoint(x: self.frame.size.width\/2.0, y: self.frame.size.height\/2.0)\n    self.layer.addSublayer(circleLayer)\n\n    crossPathLayer.path = crossPath\n    crossPathLayer.fillColor = UIColor.clearColor().CGColor;\n    crossPathLayer.strokeColor = UIColorFromRGB(0xF27474).CGColor;\n    crossPathLayer.lineCap = kCALineCapRound\n    crossPathLayer.lineWidth = 4;\n    crossPathLayer.frame = CGRect(x: 0, y: 0, width: self.frame.size.width, height: self.frame.size.height)\n    crossPathLayer.position = CGPoint(x: self.frame.size.width\/2.0, y: self.frame.size.height\/2.0)\n    self.layer.addSublayer(crossPathLayer)\n\n}\n\noverride func animate() {\n\n    var t = CATransform3DIdentity;\n    t.m34 = 1.0 \/ -500.0;\n    t = CATransform3DRotate(t, CGFloat(90.0 * M_PI \/ 180.0), 1, 0, 0);\n\n    var t2 = CATransform3DIdentity;\n    t2.m34 = 1.0 \/ -500.0;\n    t2 = CATransform3DRotate(t2, CGFloat(-M_PI), 1, 0, 0);\n\n    let animation = CABasicAnimation(keyPath: \"transform\")\n    var time = 0.3\n    animation.duration = time;\n    animation.fromValue = NSValue(CATransform3D: t)\n    animation.toValue = NSValue(CATransform3D:t2)\n    animation.removedOnCompletion = false\n    animation.fillMode = kCAFillModeForwards\n    self.circleLayer.addAnimation(animation, forKey: \"transform\")\n\n\n    var scale = CATransform3DIdentity;\n    scale = CATransform3DScale(scale, 0.3, 0.3, 0)\n\n\n    let crossAnimation = CABasicAnimation(keyPath: \"transform\")\n    crossAnimation.duration = 0.3;\n    crossAnimation.beginTime = CACurrentMediaTime() + time\n    crossAnimation.fromValue = NSValue(CATransform3D: scale)\n    crossAnimation.timingFunction = CAMediaTimingFunction(controlPoints: 0.25, 0.8, 0.7, 2.0)\n    crossAnimation.toValue = NSValue(CATransform3D:CATransform3DIdentity)\n    self.crossPathLayer.addAnimation(crossAnimation, forKey: \"scale\")\n\n    var fadeInAnimation = CABasicAnimation(keyPath: \"opacity\")\n    fadeInAnimation.duration = 0.3;\n    fadeInAnimation.beginTime = CACurrentMediaTime() + time\n    fadeInAnimation.fromValue = 0.3\n    fadeInAnimation.toValue = 1.0\n    fadeInAnimation.removedOnCompletion = false\n    fadeInAnimation.fillMode = kCAFillModeForwards\n    self.crossPathLayer.addAnimation(fadeInAnimation, forKey: \"opacity\")\n     }}\n\n\n\n\n\n\n\n class InfoAnimatedView: AnimatableView {\n\nvar circleLayer = CAShapeLayer()\nvar crossPathLayer = CAShapeLayer()\n\noverride required init(frame: CGRect) {\n    super.init(frame: frame)\n    setupLayers()\n}\n\noverride func layoutSubviews() {\n    setupLayers()\n}\n\nrequired  init(coder aDecoder: NSCoder) {\n    fatalError(\"init(coder:) has not been implemented\")\n}\n\nvar outlineCircle: CGPath  {\n    var path = UIBezierPath()\n    let startAngle: CGFloat = CGFloat((0) \/ 180.0 * M_PI)  \/\/0\n    let endAngle: CGFloat = CGFloat((360) \/ 180.0 * M_PI)   \/\/360\n    path.addArcWithCenter(CGPointMake(self.frame.size.width\/2.0, self.frame.size.width\/2.0), radius: self.frame.size.width\/2.0, startAngle: startAngle, endAngle: endAngle, clockwise: false)\n\n    var factor:CGFloat = self.frame.size.width \/ 1.5\n    path.moveToPoint(CGPoint(x: self.frame.size.width\/2.0 , y: 15.0))\n    path.addLineToPoint(CGPoint(x: self.frame.size.width\/2.0,y: factor))\n    path.moveToPoint(CGPoint(x: self.frame.size.width\/2.0,y: factor + 10.0))\n    path.addArcWithCenter(CGPoint(x: self.frame.size.width\/2.0,y: factor + 10.0), radius: 1.0, startAngle: startAngle, endAngle: endAngle, clockwise: true)\n\n    return path.CGPath\n}\n\nfunc setupLayers() {\n\n    circleLayer.path = outlineCircle\n    circleLayer.fillColor = UIColor.clearColor().CGColor;\n    circleLayer.strokeColor = UIColorFromRGB(0xF8D486).CGColor;\n    circleLayer.lineCap = kCALineCapRound\n    circleLayer.lineWidth = 4;\n    circleLayer.frame = CGRect(x: 0, y: 0, width: self.frame.size.width, height: self.frame.size.height)\n    circleLayer.position = CGPoint(x: self.frame.size.width\/2.0, y: self.frame.size.height\/2.0)\n    self.layer.addSublayer(circleLayer)\n}\n\noverride func animate() {\n\n    var colorAnimation = CABasicAnimation(keyPath:\"strokeColor\")\n    colorAnimation.duration = 1.0;\n    colorAnimation.repeatCount = HUGE\n    colorAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)\n    colorAnimation.autoreverses = true\n    colorAnimation.fromValue = UIColorFromRGB(0xF7D58B).CGColor\n    colorAnimation.toValue = UIColorFromRGB(0xF2A665).CGColor\n    circleLayer.addAnimation(colorAnimation, forKey: \"strokeColor\")\n}\n }\n\n\nclass SuccessAnimatedView: AnimatableView {\n\nvar circleLayer = CAShapeLayer()\nvar outlineLayer = CAShapeLayer()\n\n\n init() {\n    super.init(coder: NSCoder)\n    self.setupLayers()\n    circleLayer.strokeStart = 0.0\n    circleLayer.strokeEnd = 0.0\n}\n\noverride init(frame: CGRect) {\n    super.init(frame: frame)\n    setupLayers()\n    circleLayer.strokeStart = 0.0\n    circleLayer.strokeEnd = 0.0\n}\n\nrequired  init(coder aDecoder: NSCoder) {\n    fatalError(\"init(coder:) has not been implemented\")\n}\n\noverride func layoutSubviews() {\n    setupLayers()\n}\n\n\nvar outlineCircle: CGPath {\n    var path = UIBezierPath()\n    let startAngle: CGFloat = CGFloat((0) \/ 180.0 * M_PI)  \/\/0\n    let endAngle: CGFloat = CGFloat((360) \/ 180.0 * M_PI)   \/\/360\n    path.addArcWithCenter(CGPointMake(self.frame.size.width\/2.0, self.frame.size.height\/2.0), radius: self.frame.size.width\/2.0, startAngle: startAngle, endAngle: endAngle, clockwise: false)\n\n    return path.CGPath\n}\n\nvar path: CGPath {\n    var path = UIBezierPath()\n    var startAngle:CGFloat = CGFloat((60) \/ 180.0 * M_PI) \/\/60\n    var endAngle:CGFloat = CGFloat((200) \/ 180.0 * M_PI)  \/\/190\n    path.addArcWithCenter(CGPointMake(self.frame.size.width\/2.0, self.frame.size.height\/2.0), radius: self.frame.size.width\/2.0, startAngle: startAngle, endAngle: endAngle, clockwise: false)\n    path.addLineToPoint(CGPoint(x: 36.0 - 10.0 ,y: 60.0 - 10.0))\n    path.addLineToPoint(CGPoint(x: 85.0 - 20.0, y: 30.0 - 20.0))\n\n    return path.CGPath\n\n}\n\n\nfunc setupLayers() {\n\n    outlineLayer.position = CGPointMake(0,\n        0);\n    outlineLayer.path = outlineCircle\n    outlineLayer.fillColor = UIColor.clearColor().CGColor;\n    outlineLayer.strokeColor = UIColor(red: 150.0\/255.0, green: 216.0\/255.0, blue: 115.0\/255.0, alpha: 1.0).CGColor;\n    outlineLayer.lineCap = kCALineCapRound\n    outlineLayer.lineWidth = 4;\n    outlineLayer.opacity = 0.1\n    self.layer.addSublayer(outlineLayer)\n\n    circleLayer.position = CGPointMake(0,\n        0);\n    circleLayer.path = path\n    circleLayer.fillColor = UIColor.clearColor().CGColor;\n    circleLayer.strokeColor = UIColor(red: 150.0\/255.0, green: 216.0\/255.0, blue: 115.0\/255.0, alpha: 1.0).CGColor;\n    circleLayer.lineCap = kCALineCapRound\n    circleLayer.lineWidth = 4;\n    circleLayer.actions = [\n        \"strokeStart\": NSNull(),\n        \"strokeEnd\": NSNull(),\n        \"transform\": NSNull()\n    ]\n\n    self.layer.addSublayer(circleLayer)\n}\n\noverride func animate() {\n    let strokeStart = CABasicAnimation(keyPath: \"strokeStart\")\n    let strokeEnd = CABasicAnimation(keyPath: \"strokeEnd\")\n    var factor = 0.045\n    strokeEnd.fromValue = 0.00\n    strokeEnd.toValue = 0.93\n    strokeEnd.duration = 10.0*factor\n    var timing = CAMediaTimingFunction(controlPoints: 0.3, 0.6, 0.8, 1.2)\n    strokeEnd.timingFunction = timing\n\n    strokeStart.fromValue = 0.0\n    strokeStart.toValue = 0.68\n    strokeStart.duration =  7.0*factor\n    strokeStart.beginTime =  CACurrentMediaTime() + 3.0*factor\n    strokeStart.fillMode = kCAFillModeBackwards\n    strokeStart.timingFunction = timing\n    circleLayer.strokeStart = 0.68\n    circleLayer.strokeEnd = 0.93\n    self.circleLayer.addAnimation(strokeEnd, forKey: \"strokeEnd\")\n    self.circleLayer.addAnimation(strokeStart, forKey: \"strokeStart\")\n}\n\n}\n\nfunc UIColorFromRGB(rgbValue: UInt) -&gt; UIColor {\nreturn UIColor(\n    red: CGFloat((rgbValue &amp; 0xFF0000) &gt;&gt; 16) \/ 255.0,\n    green: CGFloat((rgbValue &amp; 0x00FF00) &gt;&gt; 8) \/ 255.0,\n    blue: CGFloat(rgbValue &amp; 0x0000FF) \/ 255.0,\n    alpha: CGFloat(1.0)\n)\n}\n<\/code><\/pre>\n<p>All the override init are red. If you copy this into Xcode 6.3 with Swift 1.2 you&#8217;ll see errors everywhere. I managed to get most of them except I get one error at self.view.addSubview(contentView) of &#8220;expected declaration.&#8221;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Can someone help me update the syntax to SweetAlert. It will then be available for everyone to use. \/\/ SweetAlert.swift \/\/ SweetAlert \/\/ \/\/ Created by Codester on 11\/3\/14. \/\/ Copyright (c) 2014 Codester. All rights reserved. \/\/ import Foundation import UIKit import QuartzCore enum AlertStyle { case Success,Error,Warning,None case CustomImag(imageFile:String) } class SweetAlert: UIViewController [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7822","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7822","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7822"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7822\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7822"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}