void configureCell(UITableViewCell cell, NSIndexPath indexPath, string autoCompleteString) { //NSAttributedString boldedString; var attributedTextSupport = cell.TextLabel.RespondsToSelector(new Selector("setAttributedText:")); if (attributedTextSupport && this.ApplyBoldEffectToAutoCompleteSuggestions) { //TODO } var autoCompleteObject = this.AutoCompleteSuggestions [indexPath.Row]; if (autoCompleteObject is MLPAutoCompletionObject) { autoCompleteObject = null; if (!(autoCompleteDelegate.ShouldConfigureCell(this, cell, autoCompleteString, (MLPAutoCompletionObject)autoCompleteObject, indexPath))) { return; } } cell.TextLabel.TextColor = this.TextColor; cell.TextLabel.Font = this.Font; cell.TextLabel.Text = autoCompleteString; //TODO // // if (AutoCompleteTableCellTextColor) { // cell.TextLabel.TextColor = this.autoCompleteTableCellTextColor; // } // if(boldedString){ // if ([cell.textLabel respondsToSelector:@selector(setAttributedText:)]) { // [cell.textLabel setAttributedText:boldedString]; // } else{ // [cell.textLabel setText:string]; // [cell.textLabel setFont:[UIFont fontWithName:self.font.fontName size:self.autoCompleteFontSize]]; // } // // } else { // [cell.textLabel setText:string]; // [cell.textLabel setFont:[UIFont fontWithName:self.font.fontName size:self.autoCompleteFontSize]]; // } // // cell.accessibilityLabel = [[self class] accessibilityLabelForIndexPath:indexPath]; // // if(self.autoCompleteTableCellTextColor){ // [cell.textLabel setTextColor:self.autoCompleteTableCellTextColor]; // } }
void configureCell(UITableViewCell cell, NSIndexPath indexPath, string autoCompleteString) { NSMutableAttributedString boldedString = null; var attributedTextSupport = cell.TextLabel.RespondsToSelector(new Selector("setAttributedText:")); if (attributedTextSupport && this.ApplyBoldEffectToAutoCompleteSuggestions) { var boldedAttributes = new UIStringAttributes { Font = UIFont.BoldSystemFontOfSize(UIFont.SystemFontSize) }; var startIndex = autoCompleteString.ToLower().IndexOf(this.Text.ToLower()); var totalLength = autoCompleteString.Length; boldedString = new NSMutableAttributedString(autoCompleteString); if (startIndex != -1) { var start = startIndex + Text.Length; var length = totalLength - Text.Length; NSRange range = new NSRange(start, length); if ((start + length) <= totalLength) { boldedString.SetAttributes(boldedAttributes.Dictionary, range); } } } var autoCompleteObject = this.AutoCompleteSuggestions [indexPath.Row]; if (autoCompleteObject is MLPAutoCompletionObject) { autoCompleteObject = null; if (!(autoCompleteDelegate.ShouldConfigureCell(this, cell, autoCompleteString, (MLPAutoCompletionObject)autoCompleteObject, indexPath))) { return; } } cell.TextLabel.TextColor = this.TextColor; cell.TextLabel.Font = this.Font; cell.TextLabel.Text = autoCompleteString; if (AutoCompleteTableCellTextColor != null) { cell.TextLabel.TextColor = this.AutoCompleteTableCellTextColor; } if (boldedString != null) { cell.TextLabel.AttributedText = boldedString; } else { cell.TextLabel.Text = autoCompleteString; } //TODO // // if (AutoCompleteTableCellTextColor) { // cell.TextLabel.TextColor = this.autoCompleteTableCellTextColor; // } // if(boldedString){ // if ([cell.textLabel respondsToSelector:@selector(setAttributedText:)]) { // [cell.textLabel setAttributedText:boldedString]; // } else{ // [cell.textLabel setText:string]; // [cell.textLabel setFont:[UIFont fontWithName:self.font.fontName size:self.autoCompleteFontSize]]; // } // // } else { // [cell.textLabel setText:string]; // [cell.textLabel setFont:[UIFont fontWithName:self.font.fontName size:self.autoCompleteFontSize]]; // } // // cell.accessibilityLabel = [[self class] accessibilityLabelForIndexPath:indexPath]; // // if(self.autoCompleteTableCellTextColor){ // [cell.textLabel setTextColor:self.autoCompleteTableCellTextColor]; // } }