 		_tagFieldMaxX = 0.0
 		_tagFieldMinY = _outerMergine
 		var tagFieldMaxY = CGFloat( 0.0 )
-		for ( _, value ) in _tagFields.sort( { $0.0 < $1.0 } )
-		{
-			value.frame = CGRectMake( _tagFieldMaxX + _outerMergine, _tagFieldMinY, value.frame.width, value.frame.height )
+		for ( _, value ) in _tagFields.sorted( by: { $0.0 < $1.0 } )
+		{
+			value.frame = CGRect( x: _tagFieldMaxX + _outerMergine, y: _tagFieldMinY, width: value.frame.width, height: value.frame.height )
 			if frame.width - _outerMergine * 2 < value.frame.width
 			{
-				value.frame = CGRectMake( _outerMergine, value.frame.maxY + _outerMergine, frame.width - _outerMergine * 2, value.frame.height )
+				value.frame = CGRect( x: _outerMergine, y: value.frame.maxY + _outerMergine, width: frame.width - _outerMergine * 2, height: value.frame.height )
 			}
 			else if frame.width - _outerMergine < value.frame.maxX
 			{

	{
		if 0 < tagField.text!.characters.count
		{
			if ( tagField.text! as NSString ).substringToIndex( _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 )
	}
	// --------------------------------------------------------------------------------------------
	func updateLayout()

	// --------------------------------------------------------------------------------------------
	// layout functions
	// --------------------------------------------------------------------------------------------
	func addTag( tagString: String, userData: Any? = nil )
	{
		let tagField				= UITextField( frame: CGRect( x: 0, y: 0, width: 60, height: 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.tintColor			= _addButtonTextColor
		tagField.font				= _font
		tagField.textAlignment		= NSTextAlignment.center
		tagField.delegate			= self
		tagField.borderStyle		= UITextBorderStyle.roundedRect
		tagField.returnKeyType		= UIReturnKeyType.done
		tagField.tag				= _tagIndex
		tagField.isEnabled			= _enableEdit
		tagField.becomeFirstResponder()
		tagField.sizeToFit()
		_scrollView.addSubview( tagField )
		_tagFields[ _tagIndex ] = tagField
		_userDatum[ _tagIndex ] = userData
		fitTag( tagField: tagField )
		updateLayout()
		_tagIndex += 1
		hideCharactorCount()
	}
	// --------------------------------------------------------------------------------------------
	func removeTag( tagField: UITextField )
	{
		_tagFields.removeValue( forKey: tagField.tag )
		_userDatum.removeValue( forKey: tagField.tag )
		tagField.removeFromSuperview()
	}
	// --------------------------------------------------------------------------------------------
