Search This Blog

Hiển thị các bài đăng có nhãn Nativation Bar. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn Nativation Bar. Hiển thị tất cả bài đăng

Thứ Hai, 20 tháng 11, 2017

Ẩn NativationBar khi vuốt in IOS

extension DetailViewController : UIScrollViewDelegate {
    
    
    func scrollViewDidScroll(_ scrollView: UIScrollView) // any offset changes
    {
        
        
    }
    func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
        
        if(velocity.y>0) {
            
            UIView.animate(withDuration: 2.5, delay: 0, options: UIViewAnimationOptions(), animations: {
                self.navigationController?.setNavigationBarHidden(true, animated: true)
                //self.navigationController?.setToolbarHidden(true, animated: true)
                print("Hide")

                
            }, completion: nil)
            
        } else {
            UIView.animate(withDuration: 2.5, delay: 0, options: UIViewAnimationOptions(), animations: {
                self.navigationController?.setNavigationBarHidden(false, animated: true)
                //self.navigationController?.setToolbarHidden(false, animated: true)
                print("Unhide")

            }, completion: nil)
        }

        
    }
    

}

Chủ Nhật, 10 tháng 9, 2017

Fix loi PageView bị nativation che Controler view in IOS



- Chỉ cần vào property -- > un check Under Top Bar




Ẩn nativation in IOS


self.navigationController?.setNavigationBarHidden(true, animated: true)

Thứ Năm, 31 tháng 8, 2017

Tham khảo cách cập nhật màu Nativation bằng code

self.navigationBar.barTintColor = [UIColor blueColor];
self.navigationBar.tintColor = [UIColor whiteColor];
self.navigationBar.translucent = NO;

Cài đặt Nativation Bar

func initBtnBar(){
        
        let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 30, height: 30))
        imageView.contentMode = .scaleAspectFit
        let image = UIImage(named: "logo-white.png")
        imageView.image = image
        navigationItem.titleView = imageView
        //navigationItem.titleView?.sizeToFit()
        
        
        let myBackButton = UIButton(type: UIButtonType.custom)
        myBackButton.frame = CGRect(x: 0, y: 0, width: 35.0, height: 35.0)
        //myBackButton.addTarget(self, action: #selector(self.btnMenuLeftClicked), for: .touchUpInside)
        myBackButton.setImage( UIImage(named: "icon-menu.png")?.resizedImageWithinRect( rectSize: CGSize(width: 35, height: 35)), for: .normal )
        
        let myBackButtonBtn = UIBarButtonItem(customView: myBackButton)
        
        let myBackButtonBtnMargin = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.fixedSpace, target: nil, action: nil)
        myBackButtonBtnMargin.width = -12
        self.navigationItem.leftBarButtonItems  = [myBackButtonBtnMargin,myBackButtonBtn]
        
        
        let myBackButtonRight = UIButton(type: UIButtonType.custom)
        myBackButtonRight.frame = CGRect(x: 0, y: 0, width: 35.0, height: 35.0)
        //myBackButtonRight.addTarget(self, action: #selector(self.btnMenuRightClicked), for: .touchUpInside)
        myBackButtonRight.setImage(UIImage(named: "icon_send_office.png")?.resizedImageWithinRect(rectSize: CGSize(width: 35, height: 35)), for: .normal)
        
        let myBackButtonRightBtn = UIBarButtonItem(customView: myBackButtonRight)
        
        let myBackButtonRightBtnMargin = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.fixedSpace, target: nil, action: nil)
        myBackButtonRightBtnMargin.width = -12
        self.navigationItem.rightBarButtonItems  = [myBackButtonRightBtnMargin,myBackButtonRightBtn]
        
        

 }


- Gắn thêm : 

extension UIImage {
    
    /// Returns a image that fills in newSize
    func resizedImage(newSize: CGSize) -> UIImage {
        // Guard newSize is different
        guard self.size != newSize else { return self }
        
        UIGraphicsBeginImageContextWithOptions(newSize, false, 0.0);
        self.draw(in: CGRect(x:0, y:0, width:newSize.width,height: newSize.height))
        let newImage: UIImage = UIGraphicsGetImageFromCurrentImageContext()!
        UIGraphicsEndImageContext()
        return newImage
    }
    
    /// Returns a resized image that fits in rectSize, keeping it's aspect ratio
    /// Note that the new image size is not rectSize, but within it.
    func resizedImageWithinRect(rectSize: CGSize) -> UIImage {
        let widthFactor = size.width / rectSize.width
        let heightFactor = size.height / rectSize.height
        
        var resizeFactor = widthFactor
        if size.height > size.width {
            resizeFactor = heightFactor
        }
        
        let newSize = CGSize(width:size.width/resizeFactor,height: size.height/resizeFactor)
        let resized = resizedImage(newSize: newSize)
        return resized
    }
    
}

Thứ Ba, 15 tháng 8, 2017

Tạo navigator và di chuyễn các màn hỉnh ios

// tạo navigator

Editor -- > Embed in --> Navigator controler 

// di chuyen toi man hinh và truyền dữ liệu

 let sb = UIStoryboard(name: "Main", bundle: nil)
        let manHinhXanh = sb.instantiateViewController(withIdentifier: "ManHinhXanh") as! ManHinhXanhViewController

  manHinhXanh.textHoTen = txtText.text
  self.navigationController?.pushViewController(manHinhXanh, animated: true)

* day man hinh hien tai ra 

self.navigationController?.popViewController(animated: true)

* day ve man hinh goc 


self.navigationController?.popToRootViewController(animated: true)

* Day toi mot man hinh

let sb = UIStoryboard(name: "Main", bundle: nil)
let manHinh = sb.instantiateViewController(withIdentifier: "ManHinhXanh") as! ManHinhXanhViewController
        
        self.navigationController?.popToViewController(manHinh, animated: true)


// vong doi 


   // chạy trước khi hiển thị màn hình
   override func viewWillAppear(_ animated: Bool) {
        print("viewWillAppear() : Đỏ ")
        txtTextXanh.text = textHoTen ;
    }
    
    // chạy sau khi hiển thị giao diện
    override func viewDidAppear(_ animated: Bool) {
        print("viewDidAppear() : Đỏ ")
        
    }
    
   // trước khi mất giao diện
    override func viewWillDisappear(_ animated: Bool) {
        print("viewWillDisappear() : Đỏ ")
    }
    
    // sau khi mất giao diện
    override func viewDidDisappear(_ animated: Bool) {
        print("viewWillDisappear() : Đỏ ")
    }