public bool IsPartialStringValid(ref NSString partialString, ref NSRange proposedSelectedRange, NSString originalString, NSRange originalSelectedRange, ref NSString errorDescription) { AttributedString.SetAttributes(DefaultAttributesDictionary, new NSRange(0, AttributedString.Length)); var newAttributes = new NSMutableDictionary(DefaultAttributesDictionary); #if __UNIFIED__ newAttributes[NSStringAttributeKey.ForegroundColor] = NSColor.Red; #else newAttributes[NSAttributedString.ForegroundColorAttributeName] = NSColor.Red; #endif // __UNIFIED__ var x = new NSMutableAttributedString(partialString, newAttributes); x.SetAttributes(newAttributes, new NSRange(0, partialString.Length)); AttributedString.SetString(x); ////AttributedString.AddAttribute((NSString)"NSForegroundColorAttributeName", NSColor.Red, new NSRange(0, theString.Length)); if (TextUpdateCallback != null) { TextUpdateCallback(partialString, INTV.Shared.Behavior.ValidEmailAddressBehavior.IsValidEmailAddress(partialString)); } return(true); }