Created
December 17, 2020 10:34
-
-
Save maxxfrazer/d1168facd3b303a4e648c6a24b844d74 to your computer and use it in GitHub Desktop.
Initial UIViewController for Agora Broadcasting Blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import AgoraRtcKit | |
class ViewController: UIViewController { | |
var joinButton: UIButton? | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
addJoinButton() | |
} | |
@objc func showChannelView() { | |
self.present(ChannelViewController(), animated: true) | |
} | |
/// Adds a button which says "Join" to the view | |
/// This button takes you to the `ChannelViewController` | |
func addJoinButton() { | |
if self.joinButton != nil { | |
return | |
} | |
let button = UIButton(type: .custom) | |
button.setTitle("Join", for: .normal) | |
button.setTitleColor(.label, for: .normal) | |
button.setTitleColor(.secondaryLabel, for: .focused) | |
button.backgroundColor = .systemGray | |
button.addTarget(self, action: #selector(showChannelView), for: .touchUpInside) | |
self.view.addSubview(button) | |
button.frame = CGRect( | |
origin: CGPoint(x: self.view.bounds.width / 2 - 75, y: self.view.bounds.height / 2 - 25), | |
size: CGSize(width: 150, height: 50) | |
) | |
button.autoresizingMask = [ | |
.flexibleTopMargin, .flexibleBottomMargin, .flexibleLeftMargin, .flexibleRightMargin | |
] | |
button.backgroundColor = .systemGreen | |
button.layer.cornerRadius = 25 | |
self.joinButton = button | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment