...
|
...
|
@@ -8,9 +8,15 @@ |
|
|
|
|
|
#import "YH_RoomSecretViewController.h"
|
|
|
|
|
|
@interface YH_RoomSecretViewController()
|
|
|
|
|
|
@end
|
|
|
|
|
|
@implementation YH_RoomSecretViewController
|
|
|
{
|
|
|
void (^completionBlock)(NSDictionary *dic, BOOL success);
|
|
|
UITextField *textField;
|
|
|
UIButton *startButton;
|
|
|
}
|
|
|
|
|
|
+ (void)showInController:(UIViewController *)aController completionBlock:(void (^)(NSDictionary *, BOOL))block {
|
...
|
...
|
@@ -33,14 +39,84 @@ |
|
|
[self.view addSubview:bg];
|
|
|
bg.frame = CGRectMake(0, 0, 280, 250);
|
|
|
bg.center = self.view.center;
|
|
|
bg.backgroundColor = [UIColor whiteColor];
|
|
|
CGRect frame = bg.frame;
|
|
|
frame.origin.y = 170;
|
|
|
bg.frame = frame;
|
|
|
bg.userInteractionEnabled = YES;
|
|
|
|
|
|
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 50, 280, 19)];
|
|
|
titleLabel.font = [UIFont systemFontOfSize:18];
|
|
|
titleLabel.textAlignment = NSTextAlignmentCenter;
|
|
|
titleLabel.text = @"房间秘钥";
|
|
|
[bg addSubview:titleLabel];
|
|
|
|
|
|
UIView *secretBg = [[UIView alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(titleLabel.frame)+44, 250, 40)];
|
|
|
secretBg.backgroundColor = [UIColor groupTableViewBackgroundColor];
|
|
|
[bg addSubview:secretBg];
|
|
|
UIImageView *keyImage = [[UIImageView alloc] initWithFrame:CGRectMake(8, 12, 15, 16)];
|
|
|
keyImage.image = [UIImage imageNamed:@"home_icon_roomkey"];
|
|
|
[secretBg addSubview:keyImage];
|
|
|
|
|
|
UIView *bar = [[UIView alloc] initWithFrame:CGRectMake(31, 12, 0.5, 16)];
|
|
|
bar.backgroundColor = [UIColor lightGrayColor];
|
|
|
[secretBg addSubview:bar];
|
|
|
|
|
|
textField = [[UITextField alloc] initWithFrame:CGRectMake(35, 0, 210, 40)];
|
|
|
textField.font = [UIFont systemFontOfSize:14];
|
|
|
textField.keyboardType = UIKeyboardTypeNumberPad;
|
|
|
textField.keyboardAppearance = UIKeyboardAppearanceDark;
|
|
|
[secretBg addSubview:textField];
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textDidChange:) name:UITextFieldTextDidChangeNotification object:nil];
|
|
|
|
|
|
startButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
startButton.frame = CGRectMake(15, CGRectGetMaxY(secretBg.frame)+20, 250, 40);
|
|
|
startButton.titleLabel.font = [UIFont boldSystemFontOfSize:17];
|
|
|
[startButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
|
|
startButton.backgroundColor = [UIColor lightGrayColor];
|
|
|
[bg addSubview:startButton];
|
|
|
[startButton addTarget:self action:@selector(startButtonPressed) forControlEvents:UIControlEventTouchUpInside];
|
|
|
[startButton setTitle:@"开始直播" forState:UIControlStateNormal];
|
|
|
|
|
|
UIButton *closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
closeButton.frame = CGRectMake(280-18-8, 8, 18, 18);
|
|
|
[closeButton setImage:[UIImage imageNamed:@"home_btn_close"] forState:UIControlStateNormal];
|
|
|
[bg addSubview:closeButton];
|
|
|
[closeButton addTarget:self action:@selector(closeButtonPressed) forControlEvents:UIControlEventTouchUpInside];
|
|
|
}
|
|
|
|
|
|
- (void)textDidChange:(NSNotification *)sender {
|
|
|
UITextField *txtFild = sender.object;
|
|
|
if (txtFild.text.length) {
|
|
|
startButton.backgroundColor = [UIColor blackColor];
|
|
|
}else {
|
|
|
startButton.backgroundColor = [UIColor lightGrayColor];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- (void)startButtonPressed {
|
|
|
if (!textField.text.length) {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- (void)viewDidAppear:(BOOL)animated {
|
|
|
[super viewDidAppear:animated];
|
|
|
[UIView animateWithDuration:0.3 animations:^{
|
|
|
self.view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.7];
|
|
|
} completion:^(BOOL finished) {
|
|
|
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
- (void)closeButtonPressed {
|
|
|
[UIView animateWithDuration:0.3 animations:^{
|
|
|
self.view.alpha = 0;
|
|
|
} completion:^(BOOL finished) {
|
|
|
[self.view removeFromSuperview];
|
|
|
[self removeFromParentViewController];
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
- (void)setCompletionBlock:(void (^)(NSDictionary *, BOOL))block {
|
...
|
...
|
|