PaystackHQ / paystack-ios

Paystack SDK for iOS. Accept Payments on iOS
http://paystack.com
MIT License
26 stars 26 forks source link

PSTCKPaymentCardTextField not displaying on view #13

Closed SirOlaoluwani closed 6 years ago

SirOlaoluwani commented 6 years ago

Hello,

Trying to integrate Paystack with my app. Using PSTCKPaymentCardTextField as described in the guide, but it just doesn't display anything on my view when I run the app.

import UIKit
import Paystack

class PaymentViewController: UIViewController, PSTCKPaymentCardTextFieldDelegate {

    let paymentTextField: PSTCKPaymentCardTextField = {
       let ptf = PSTCKPaymentCardTextField()
        return ptf
    }()

    func setupPaymentTextField() {
        let paymentFormWidth = self.view.frame.width - 30
        paymentTextField.frame = CGRect(x: 15, y: 15, width: paymentFormWidth, height: 44)
        paymentTextField.delegate = self
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .white

        view.addSubview(paymentTextField)
        setupPaymentTextField()

    }

}

Am i doing something wrong? Please help me out. Thanks

Note: I am new to swift language

SirOlaoluwani commented 6 years ago

using autolayout, solved the issue.

func setupPaymentTextField() {
        paymentTextField.delegate = self

        paymentTextField.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
        paymentTextField.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
        paymentTextField.widthAnchor.constraint(equalTo: view.widthAnchor, constant: -30).isActive = true
        paymentTextField.heightAnchor.constraint(equalToConstant: 44).isActive = true
}