         layoutIfNeeded()
         _bottomConstraint.constant = bounds.height
         
-        let delay = toastDuration == nil ? Double(_label.text!.lengthOfBytesUsingEncoding(NSUTF8StringEncoding)) * 0.1 : toastDuration!
-        
-        UIView.animateWithDuration(animateDuration, delay: delay, options: .CurveEaseInOut, animations: {
+        let delay = toastDuration == nil ? Double(_label.text!.lengthOfBytes(using: String.Encoding.utf8)) * 0.1 : toastDuration!
+        
+        UIView.animate(withDuration: animateDuration, delay: delay, options: .curveEaseInOut, animations: {
             self.layoutIfNeeded()
         }) { (bol) in
             self.removeFromSuperview()
         }
     }
-}+}

            
            
            let rightViewCenterY = NSLayoutConstraint(item: _rightView,
                                                      attribute: .CenterY,
                                                      relatedBy: .Equal,
                                                      toItem: self,
                                                      attribute: .CenterY,
                                                      multiplier: 1.0,
                                                      constant: 0.0)
            
            let rightViewTrailing = NSLayoutConstraint(item: _rightView,
                                                       attribute: .Trailing,
                                                       relatedBy: .Equal,
                                                       toItem: self,
                                                       attribute: .Trailing,
                                                       multiplier: 1.0,
                                                       constant: -edgeInsets.right)
            
            let rightViewWidth = NSLayoutConstraint(item: _rightView,
                                                    attribute: .Width,
                                                    relatedBy: .Equal,
                                                    toItem: nil,
                                                    attribute: .NotAnAttribute,
                                                    multiplier: 1.0,
                                                    constant: 0)
            rightViewWidth.priority = 1
            
            addConstraints([rightViewCenterY, rightViewTrailing, rightViewWidth])
        }
        
        
        // Adding a label
        _label = UILabel(frame: CGRectZero)
        _label.translatesAutoresizingMaskIntoConstraints = false
        _label.textColor = textColor
        _label.numberOfLines = 0
        _label.lineBreakMode = .ByWordWrapping
        _label.font = font
        _label.textAlignment = textAlignment
        addSubview(_label)
        
        addConstraint(NSLayoutConstraint(item: _label,
            attribute: .CenterY,
            relatedBy: .Equal,
            toItem: self,
            attribute: .CenterY,
            multiplier: 1.0,
            constant: 0.0))
        
        addConstraint(NSLayoutConstraint(item: _label,
            attribute: .Trailing,
            relatedBy: .Equal,
            toItem: _haveRightView ? rightView : self,
            attribute:  _haveRightView ? .Leading : .Trailing,
            multiplier: 1.0,
            constant: -edgeInsets.right))
        
        addConstraint(NSLayoutConstraint(item: _label,
            attribute: .Leading,
            relatedBy: .Equal,
            toItem: _haveLeftView ? leftView : self,
            attribute: _haveLeftView ? .Trailing : .Leading,
            multiplier: 1.0,
            constant: edgeInsets.left))
        
    }
    

        _label.text = msg
        _label.sizeToFit()
        
        
        frame = CGRect(x: 0.0, y: 0.0, width: inView.bounds.width, height: _label.bounds.height + edgeInsets.top + edgeInsets.bottom)
        
        inView.addSubview(self)
        
        _bottomConstraint = NSLayoutConstraint(item: self,
                                               attribute: .bottom,
                                               relatedBy: .equal,
                                               toItem: inView,
                                               attribute: .bottom,
                                               multiplier: 1.0,
                                               constant: bounds.height)
        
        inView.addConstraint(_bottomConstraint)
        
        inView.addConstraint(NSLayoutConstraint(item: self,
                                                attribute: .trailing,
                                                relatedBy: .equal,
                                                toItem: inView,
                                                attribute: .trailing,
                                                multiplier: 1.0,
                                                constant: 0.0))
        
        inView.addConstraint(NSLayoutConstraint(item: self,
                                                attribute: .leading,
                                                relatedBy: .equal,
                                                toItem: inView,
                                                attribute: .leading,
                                                multiplier: 1.0,
                                                constant: 0.0))
        
        inView.addConstraint(NSLayoutConstraint(item: self,
                                                attribute: .height,
                                                relatedBy: .equal,
                                                toItem: nil,
                                                attribute: .notAnAttribute,
                                                multiplier: 1.0,
                                                constant: bounds.height))
        
        slideUp()
        
