 	{
 		if 0 < tagField.text!.characters.count
 		{
-			if ( tagField.text! as NSString ).substringToIndex( _tagPrefix.characters.count ) != _tagPrefix
+			if ( tagField.text! as NSString ).substring( to: _tagPrefix.characters.count ) != _tagPrefix
 			{
 				tagField.text = _tagPrefix + tagField.text!
 			}
 		}
 		tagField.sizeToFit()
-		tagField.frame = CGRectMake( tagField.layer.position.x, tagField.layer.position.y, tagField.frame.width + _innerMergine * 2, tagField.frame.height + _innerMergine * 2 )
+		tagField.frame = CGRect( x: tagField.layer.position.x, y: tagField.layer.position.y, width: tagField.frame.width + _innerMergine * 2, height: tagField.frame.height + _innerMergine * 2 )
 	}
 	// --------------------------------------------------------------------------------------------
 	func updateLayout()

	// --------------------------------------------------------------------------------------------
	// layout functions
	// --------------------------------------------------------------------------------------------
	func addTag( tagString: String )
	{
		let tagField				= UITextField( frame: CGRectMake( 0, 0, 60, 30 ) )
		tagField.layer.anchorPoint	= CGPoint( x: 0.0, y: 0.0 )
		tagField.layer.position		= CGPoint( x: _outerMergine + _tagFieldMaxX, y: _outerMergine + _tagFieldMinY )
		tagField.backgroundColor	= _tagBackgroundColor
		tagField.textColor			= _tagTextColor
		tagField.text				= tagString
		tagField.font				= _font
		tagField.textAlignment		= NSTextAlignment.Center
		tagField.delegate			= self
		tagField.borderStyle		= UITextBorderStyle.RoundedRect
		tagField.returnKeyType		= UIReturnKeyType.Done
		tagField.tag				= _tagIndex
		tagField.becomeFirstResponder()
		tagField.sizeToFit()
		_scrollView.addSubview( tagField )
		_tagFields[ _tagIndex ] = tagField
		fitTag( tagField )
		updateLayout()
		_tagIndex += 1
	}
	// --------------------------------------------------------------------------------------------
	func removeTag( tagField: UITextField )
	{
		_tagFields.removeValueForKey( tagField.tag )
		tagField.removeFromSuperview()
	}
	// --------------------------------------------------------------------------------------------

				tagFieldMaxY = _addButton.frame.maxY
			}
		}
		_scrollView.contentSize = CGSize( width: frame.width, height: tagFieldMaxY + _outerMergine )
		if _autoGlowHeight == true
		{
			frame = CGRect( x: _basePosition.x, y: _basePosition.y, width: _baseSize.width, height: max( _baseSize.height, _scrollView.contentSize.height ) )
			_scrollView.frame = CGRect( x: 0, y: 0, width: frame.width, height: frame.height )
			delegate?.onChangedLayoutTag!( sender: self )
		}
	}
	// --------------------------------------------------------------------------------------------
	func updateCharactorCount()
	{
		_tagCharCountLabel.isHidden		  = false
		_tagCharCountLabel.text			  = _targetTextField.text!.characters.count.description + " / " + _tagMaxCharactors.description
		_tagCharCountLabel.layer.position = CGPoint( x: _targetTextField.frame.maxX, y: _targetTextField.frame.maxY + 5 )
		_tagCharCountLabel.text			  = _targetTextField.text!.characters.count.description + " / " + _tagMaxCharactors.description
	}
	// --------------------------------------------------------------------------------------------
	func hideCharactorCount()
	{
		_tagCharCountLabel.isHidden = true
	}

	// --------------------------------------------------------------------------------------------
