Skip to content

Commit

Permalink
Merge pull request #108 from appsailor/feature/ui-options-extra
Browse files Browse the repository at this point in the history
This patch allows a user to specify additional options - hide/show circular view, corner radius for buttons etc.
  • Loading branch information
vikmeup committed Oct 19, 2015
2 parents 28b40ff + 0028d47 commit bc61d7b
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions SCLAlertView/SCLAlertView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ public class SCLAlertView: UIViewController {

// UI Options
public var showCloseButton = true
public var showCircularIcon = true
public var contentViewCornerRadius : CGFloat = 5.0
public var fieldCornerRadius : CGFloat = 3.0
public var buttonCornerRadius : CGFloat = 3.0

// Members declaration
var baseView = UIView()
Expand Down Expand Up @@ -126,7 +130,7 @@ public class SCLAlertView: UIViewController {
baseView.addSubview(contentView)
// Content View
contentView.backgroundColor = UIColor(white:1, alpha:1)
contentView.layer.cornerRadius = 5
contentView.layer.cornerRadius = contentViewCornerRadius
contentView.layer.masksToBounds = true
contentView.layer.borderWidth = 0.5
contentView.addSubview(labelTitle)
Expand Down Expand Up @@ -197,24 +201,30 @@ public class SCLAlertView: UIViewController {
var x = (sz.width - kWindowWidth) / 2
var y = (sz.height - windowHeight - (kCircleHeight / 8)) / 2
contentView.frame = CGRect(x:x, y:y, width:kWindowWidth, height:windowHeight)
contentView.layer.cornerRadius = contentViewCornerRadius
y -= kCircleHeightBackground * 0.6
x = (sz.width - kCircleHeightBackground) / 2
circleBG.frame = CGRect(x:x, y:y+6, width:kCircleHeightBackground, height:kCircleHeightBackground)

//adjust Title frame based on circularIcon show/hide flag
let titleOffset : CGFloat = showCircularIcon ? 0.0 : -12.0
labelTitle.frame = labelTitle.frame.offsetBy(dx: 0, dy: titleOffset)

// Subtitle
y = kTitleTop + kTitleHeight
y = kTitleTop + kTitleHeight + titleOffset
viewText.frame = CGRect(x:12, y:y, width: kWindowWidth - 24, height:kTextHeight)
viewText.frame = CGRect(x:12, y:y, width: viewTextWidth, height:viewTextHeight)
// Text fields
y += viewTextHeight + 14.0
for txt in inputs {
txt.frame = CGRect(x:12, y:y, width:kWindowWidth - 24, height:30)
txt.layer.cornerRadius = 3
txt.layer.cornerRadius = fieldCornerRadius
y += kTextFieldHeight
}
// Buttons
for btn in buttons {
btn.frame = CGRect(x:12, y:y, width:kWindowWidth - 24, height:35)
btn.layer.cornerRadius = 3
btn.layer.cornerRadius = buttonCornerRadius
y += kButtonHeight
}
}
Expand Down Expand Up @@ -463,6 +473,10 @@ public class SCLAlertView: UIViewController {
addButton(txt, target:self, selector:Selector("hideView"))
}

//hidden/show circular view based on the ui option
circleView.hidden = !showCircularIcon
circleBG.hidden = !showCircularIcon

// Alert view colour and images
circleView.backgroundColor = viewColor
// Spinner / icon
Expand Down

0 comments on commit bc61d7b

Please sign in to comment.