在导航堆栈中只有一个导航栏透明iOS Swift

时间:2018-03-11 06:49:09

标签: ios swift swift3 uinavigationcontroller uistoryboardsegue

我有一个导航流程的导航控制器,如下所示:

NC - > A - >乙

B通过push segue出现。

使用以下

使A的导航栏变为透明
Socket live = new Socket("##########", 50123);
InputStream input = live.getInputStream();
OutputStream output = live.getOutputStream();

并且在viewWillDisappear中半透明设置为false,以便B可以拥有通常的导航栏:

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    self.navigationController!.navigationBar.isTranslucent = true
    self.navigationController!.navigationBar.setBackgroundImage(UIImage(), for: .default)
    self.navigationController!.navigationBar.shadowImage = UIImage()
}

问题是当在B中按下后退按钮返回A时,B的导航栏会在消失之前暂时出现。如何解决这个问题?

PS:我不想为B的重写方法添加代码,因为B可能被其他导航控制器共享。

1 个答案:

答案 0 :(得分:1)

  

问题是当在B中按下Back按钮返回A时,The   B的导航栏在消失之前暂时出现。如何   解决这个问题?

您无需在<?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; require('PHPMailer.php'); require('Exception.php'); require('SMTP.php'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $name = strip_tags(trim($_POST['name'])); $name = str_replace(array('\r','\n'),array(' ',' '),$name); $email = filter_var(trim($_POST['email']), FILTER_SANITIZE_EMAIL); $tel = trim($_POST['tel']); $message = trim($_POST['message']); $secret = '6LcjwkUUAAAAAENXwZtla40jNuPJGblZkYxLkXvf'; $captcha = ''; if(isset($_POST['captcha']) && !empty($_POST['captcha'])){ $captcha=$_POST['captcha']; } if(!$captcha){ echo 'Prove that you are human'; exit; } $fields = array( 'secret' => $secret, 'response' => $_POST['captcha'], 'remoteip' => $_SERVER['REMOTE_ADDR'] ); $verifyResponse = curl_init('https://www.google.com/recaptcha/api/siteverify'); curl_setopt($verifyResponse, CURLOPT_RETURNTRANSFER, true); curl_setopt($verifyResponse, CURLOPT_TIMEOUT, 15); curl_setopt($verifyResponse, CURLOPT_POSTFIELDS, http_build_query($fields)); $responseData = json_decode(curl_exec($verifyResponse)); curl_close($verifyResponse); if ($responseData->success) { if ( empty($name) OR empty($message) OR empty($tel) OR empty($captcha) OR !filter_var($email, FILTER_VALIDATE_EMAIL)) { // Set a 400 (bad request) response code and exit. http_response_code(400); echo 'Oops! There was a problem with your submission. Please complete the form and try again.'; exit; } // Build the email content. $email_content = 'Имя: $name\n'; $email_content .= 'Телефон: $tel\n'; $email_content .= 'Email: $email\n'; $email_content .= 'Сообщение: $message\n'; // Send the email. $mail = new PHPMailer(); //Server settings $mail->SMTPDebug = 0; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'domain.tld'; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = 'info'; // SMTP username $mail->Password = 'password'; // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 587; // TCP port to connect to //Recipients $mail->setFrom('info@domain.tld', 'DOMAIN.TLD'); $mail->addAddress('info@domain.tld', 'Information'); // Add a recipient $mail->addReplyTo('info@domain.tld', 'Information'); //Content $mail->Subject = 'Новое сообщение с сайта DOMAIN.TLD' ; $mail->Body = $email_content; $success = $mail->send(); echo 'success'; } } else { http_response_code(403); echo 'Something went wrong. Please try again'; } ?> 方法中切换任何内容。只需在每个屏幕中切换viewWillDisappear方法中的所有内容。

这是你想要的吗?如果是这样,我在Github上为你做了一个示例项目,以及其他未来iOS新手。

https://github.com/glennposadas/showhidenavbar-ios

虽然它使用我非常简单的cocoapod,但您可以从我的框架和示例项目中复制所有内容。

enter image description here