程序内实现console控制台打印

2019-11-18  本文已影响0人  seventhboy

{
UIButton *logBtn = [UIButton buttonWithType:UIButtonTypeCustom];
logBtn.frame = CGRectMake(0, kStatusBarHeight, 100, 30);
[logBtn setTitle:@"console" forState:UIControlStateNormal];
logBtn.backgroundColor = UIColor.grayColor;
[logBtn setTitleColor:UIColor.greenColor forState:UIControlStateNormal];
[logBtn addTarget:self action:@selector(logBtnAction) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:logBtn];

textView = [[UITextView alloc]initWithFrame:CGRectMake(0,kStatusBarHeight+30, kScreenWidth, kScreenWidth)];
textView.backgroundColor = [UIColor.yellowColor colorWithAlphaComponent:0.25];
[self.view addSubview:textView];
textView.hidden = YES;
[self redirectSTD:STDOUT_FILENO];
[self redirectSTD:STDERR_FILENO];

}
-(void)logBtnAction{
textView.hidden = !textView.hidden;
}

上一篇 下一篇

猜你喜欢

热点阅读