Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 33 additions & 16 deletions SweetAlert/SweetAlert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ open class SweetAlert: UIViewController {
y += imageView!.frame.size.height + kHeightMargin
}

// Title
if self.titleLabel.text != nil {
// Title can never be nil, so only number of characters can represent string
if self.titleLabel.text?.characters.count != 0 {
titleLabel.frame = CGRect(x: x, y: y, width: width, height: kTitleHeight)
contentView.addSubview(titleLabel)
y += kTitleHeight + kHeightMargin
Expand Down Expand Up @@ -266,10 +266,27 @@ open class SweetAlert: UIViewController {
self.animatedView = nil
}

self.titleLabel.text = title
if subTitle != nil {
self.subTitleTextView.text = subTitle
// Hide title field if no character
if title.characters.count == 0 {
self.titleLabel.isHidden = true
}else{
self.titleLabel.text = title
self.titleLabel.isHidden = false
}


// Hide subtitle field if no character
if let st = subTitle {
if st.characters.count != 0 {
self.subTitleTextView.isHidden = false
self.subTitleTextView.text = subTitle
}
}else{
self.subTitleTextView.isHidden = true
}



buttons = []
if buttonTitle.isEmpty == false {
let button: UIButton = UIButton(type: UIButtonType.custom)
Expand Down Expand Up @@ -355,7 +372,7 @@ class CancelAnimatedView: AnimatableView {
setupLayers()
var t = CATransform3DIdentity;
t.m34 = 1.0 / -500.0;
t = CATransform3DRotate(t, CGFloat(90.0 * M_PI / 180.0), 1, 0, 0);
t = CATransform3DRotate(t, CGFloat(90.0 * Double.pi / 180.0), 1, 0, 0);
circleLayer.transform = t
crossPathLayer.opacity = 0.0
}
Expand All @@ -370,8 +387,8 @@ class CancelAnimatedView: AnimatableView {

fileprivate var outlineCircle: CGPath {
let path = UIBezierPath()
let startAngle: CGFloat = CGFloat((0) / 180.0 * M_PI) //0
let endAngle: CGFloat = CGFloat((360) / 180.0 * M_PI) //360
let startAngle: CGFloat = CGFloat((0) / 180.0 * Double.pi) //0
let endAngle: CGFloat = CGFloat((360) / 180.0 * Double.pi) //360
path.addArc(withCenter: CGPoint(x: self.frame.size.width/2.0, y: self.frame.size.width/2.0), radius: self.frame.size.width/2.0, startAngle: startAngle, endAngle: endAngle, clockwise: false)

return path.cgPath
Expand Down Expand Up @@ -412,11 +429,11 @@ class CancelAnimatedView: AnimatableView {
override func animate() {
var t = CATransform3DIdentity;
t.m34 = 1.0 / -500.0;
t = CATransform3DRotate(t, CGFloat(90.0 * M_PI / 180.0), 1, 0, 0);
t = CATransform3DRotate(t, CGFloat(90.0 * Double.pi / 180.0), 1, 0, 0);

var t2 = CATransform3DIdentity;
t2.m34 = 1.0 / -500.0;
t2 = CATransform3DRotate(t2, CGFloat(-M_PI), 1, 0, 0);
t2 = CATransform3DRotate(t2, CGFloat(-Double.pi), 1, 0, 0);

let animation = CABasicAnimation(keyPath: "transform")
let time = 0.3
Expand Down Expand Up @@ -472,8 +489,8 @@ class InfoAnimatedView: AnimatableView {

var outlineCircle: CGPath {
let path = UIBezierPath()
let startAngle: CGFloat = CGFloat((0) / 180.0 * M_PI) //0
let endAngle: CGFloat = CGFloat((360) / 180.0 * M_PI) //360
let startAngle: CGFloat = CGFloat((0) / 180.0 * Double.pi) //0
let endAngle: CGFloat = CGFloat((360) / 180.0 * Double.pi) //360
path.addArc(withCenter: CGPoint(x: self.frame.size.width/2.0, y: self.frame.size.width/2.0), radius: self.frame.size.width/2.0, startAngle: startAngle, endAngle: endAngle, clockwise: false)

let factor:CGFloat = self.frame.size.width / 1.5
Expand Down Expand Up @@ -533,16 +550,16 @@ class SuccessAnimatedView: AnimatableView {

var outlineCircle: CGPath {
let path = UIBezierPath()
let startAngle: CGFloat = CGFloat((0) / 180.0 * M_PI) //0
let endAngle: CGFloat = CGFloat((360) / 180.0 * M_PI) //360
let startAngle: CGFloat = CGFloat((0) / 180.0 * Double.pi) //0
let endAngle: CGFloat = CGFloat((360) / 180.0 * Double.pi) //360
path.addArc(withCenter: CGPoint(x: self.frame.size.width/2.0, y: self.frame.size.height/2.0), radius: self.frame.size.width/2.0, startAngle: startAngle, endAngle: endAngle, clockwise: false)
return path.cgPath
}

var path: CGPath {
let path = UIBezierPath()
let startAngle:CGFloat = CGFloat((60) / 180.0 * M_PI) //60
let endAngle:CGFloat = CGFloat((200) / 180.0 * M_PI) //190
let startAngle:CGFloat = CGFloat((60) / 180.0 * Double.pi) //60
let endAngle:CGFloat = CGFloat((200) / 180.0 * Double.pi) //190
path.addArc(withCenter: CGPoint(x: self.frame.size.width/2.0, y: self.frame.size.height/2.0), radius: self.frame.size.width/2.0, startAngle: startAngle, endAngle: endAngle, clockwise: false)
path.addLine(to: CGPoint(x: 36.0 - 10.0 ,y: 60.0 - 10.0))
path.addLine(to: CGPoint(x: 85.0 - 20.0, y: 30.0 - 20.0))
Expand Down