SCLAlertView-Swift icon indicating copy to clipboard operation
SCLAlertView-Swift copied to clipboard

Button color not changing

Open ashiqsulaimanbaryons opened this issue 9 years ago • 1 comments

In the following code i am not able to change the background color of the button, when i am giving the background colour as UIColour(red:122.0, green:100.0, blue: 30.0 , alpha: 1.0) The result is the background colour of the button turns white.

` @IBAction func clickME(sender: AnyObject) {

        let appearance = SCLAlertView.SCLAppearance(
            kTitleFont: UIFont(name: "HelveticaNeue", size: 20)!,
            kTextFont: UIFont(name: "HelveticaNeue", size: 14)!,
            kButtonFont: UIFont(name: "HelveticaNeue-Bold", size: 14)!,
            showCloseButton: false,
            contentViewColor:UIColor(red: 249.0, green: 252.0, blue: 255.0, alpha: 1.0)

        )
        // Initialize SCLAlertView using custom Appearance
        let alert = SCLAlertView(appearance: appearance)

        // Creat the subview
        let subview = UIView(frame: CGRectMake(0,0,200,250))
        let x = (subview.frame.width - 180) / 2
        subview.backgroundColor = UIColor(red: 247.0, green: 253.0, blue: 255.0, alpha: 1.0)

        //name label
        let Name = UILabel(frame: CGRectMake(x,10,180,15))
        Name.text = "Name:"
        subview.addSubview(Name)
        Name.font = UIFont(name: "SanFransisco", size: 5.0)
        Name.font.fontWithSize(5.0)
        Name.textColor = UIColor.grayColor()

        //employee name
        // let empName = UILabel(frame: CGRectMake(x,Name.frame.maxY,180,25))

        let empName = UILabel(frame: CGRectMake(x,Name.frame.maxY+2,180,25))
        empName.text = "Employee name"
        subview.addSubview(empName)
        empName.font = UIFont(name: "SanFransisco-Medium", size: 16.0)

        //dept label
        let dept = UILabel(frame: CGRectMake(x,empName.frame.maxY+5,180,25))
        dept.text = "Department:"
        subview.addSubview(dept)
        dept.font = UIFont(name: "SanFransisco", size: 5.0)
        dept.textColor = UIColor.grayColor()

        //employee dept
        let empDept = UILabel(frame: CGRectMake(x,dept.frame.maxY+2,180,25))
        empDept.text = "Employee department"
        subview.addSubview(empDept)
        empDept.font = UIFont(name: "SanFransisco-Medium", size: 16.0)


        //from label
        let from = UILabel(frame: CGRectMake(x,empDept.frame.maxY+5,180,25))
        from.text = "From:"
        subview.addSubview(from)
        from.font = UIFont(name: "SanFransisco", size: 5.0)
        from.textColor = UIColor.grayColor()
        //
        //fromDate
        let fromDate = UILabel(frame: CGRectMake(x, from.frame.maxY+2, 100, 25))
        fromDate.text = "From Sample"
        subview.addSubview(fromDate)

        //to label
        let to = UILabel(frame: CGRectMake(x,fromDate.frame.maxY+5,180,25))
        to.text = "To:"
        subview.addSubview(to)
        to.font = UIFont(name: "SanFransisco", size: 5.0)
        to.textColor = UIColor.grayColor()


        //toDate
        let toDate = UILabel(frame: CGRectMake(x, to.frame.maxY+2, 180, 25))
        toDate.text = "ToSample"
        subview.addSubview(toDate)

        // Add the subview to the alert's UI property
        alert.customSubview = subview
        alert.addButton("Accept") {
            print("Accepted")
        }

        // Add Button with Duration Status and custom Colors
        alert.addButton("Decline", backgroundColor: UIColor.redColor(), textColor: UIColor.whiteColor(), showDurationStatus: true) {
            print("Duration Button tapped")
        }

        alert.showInfo("Leave Approval", subTitle: "", duration: 10)
}

`

ashiqsulaimanbaryons avatar Aug 26 '16 12:08 ashiqsulaimanbaryons

In the following code i am not able to change the background color of the button, when i am giving the background colour as UIColour(red:122.0, green:100.0, blue: 30.0 , alpha: 1.0) UIColor takes values betwwen 0 and 1 it should be UIColour(red:122.0/255.0, green:100.0/255.0, blue: 30.0/255.0 , alpha: 1.0)

ankitagarwal007 avatar Jul 18 '17 00:07 ankitagarwal007