This question is locked. New answers and comments are not allowed.
I can change the suggestion view background color by calling
self
.autoCompleteTextView
.suggestionView
?
.backgroundColor
=
UIColor
.lightGrayColor
()
But the suggestion cells (?) remain white (see image attached below). I would like to change the appearance of these cells (font and background). How can i do that?.
3 Answers, 1 is accepted
0
Hello Armando,
Thanks for writing.
You could use the `settings` property exposed by TKDataSource. It accepts an object of type `TKDataSourceSettings` which in return exposes the `collectionView` property. This property accepts an instance of type `TKDataSourceCollectionViewSettings`. The `TKDataSourceAutoCompleteSettings` class has two methods:
You can inherit from this class, override the methods and use them to style your cells. You will need to assign your custom implementation to the `collectionView` property of the TKDataSourceSettings object assigned to the TKDataSource instance you are using TKAutoCompleteTextView with.
I hope this helps.
Regards,
Deyan
Telerik by Progress
Thanks for writing.
You could use the `settings` property exposed by TKDataSource. It accepts an object of type `TKDataSourceSettings` which in return exposes the `collectionView` property. This property accepts an instance of type `TKDataSourceCollectionViewSettings`. The `TKDataSourceAutoCompleteSettings` class has two methods:
/**
The settings that can be customized when using TKDataSource with UICollectionView.
*/
@
interface
TKDataSourceCollectionViewSettings : NSObject
/**
Defines a block function that is called when creating a new cell in UICollectionView. TKCollectionViewCell is used by default.
@param cellIdForItem The block function that will be called when creating a new cell.
*/
- (
void
)createCell:(TKDataSourceCollectionViewSettings_CreatrCellBlock __nonnull)cellIdForItem;
/**
Defines a block function that is called when initializing the cell properties.
@param initCellWithItem The block function that will be called when initializing a new cell.
*/
- (
void
)initCell:(TKDataSourceCollectionViewSettings_InitCellWithItemBlock __nonnull)initCellWithItem;
@end
You can inherit from this class, override the methods and use them to style your cells. You will need to assign your custom implementation to the `collectionView` property of the TKDataSourceSettings object assigned to the TKDataSource instance you are using TKAutoCompleteTextView with.
I hope this helps.
Regards,
Deyan
Telerik by Progress
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items
0
Philipp
Top achievements
Rank 1
answered on 25 Jan 2017, 12:28 PM
I need to do it with C#:
This doesn't work.
dataSource.Settings.CollectionView.CreateCell(delegate (UICollectionView arg1, NSIndexPath arg2, NSObject arg3) {
return new UICollectionViewCell();
});
dataSource.Settings.CollectionView.InitCell((UICollectionView arg1, NSIndexPath arg2, UICollectionViewCell arg3, NSObject arg4) => {
arg3.BackgroundColor = UIColor.Clear;
});
0
Hello Philipp,
You can try the following approach:
1. Create a custom suggestion cell by inheriting from TKAutoCompleteSuggestionCell:
As you can see, I am changing the background color of the content of the cell in the constructor.
2. Use this cell as a suggestion cell in the AutoCompleteTextView:
Let us know if you have additional questions here.
Regards,
Deyan
Telerik by Progress
You can try the following approach:
1. Create a custom suggestion cell by inheriting from TKAutoCompleteSuggestionCell:
public class PersonListViewCell : TKAutoCompleteSuggestionCell
{
public PersonListViewCell(IntPtr ptr) : base(ptr)
{
this.ContentView.BackgroundColor = new UIColor (0.91f, 0.91f, 0.91f, 1.0f);
}
public override void LayoutSubviews ()
{
base.LayoutSubviews ();
}
}
As you can see, I am changing the background color of the content of the cell in the constructor.
2. Use this cell as a suggestion cell in the AutoCompleteTextView:
TKListView listView = (TKListView)autocomplete.WeakSuggestionView;
listView.RegisterClassForCell (new Class(typeof(PersonListViewCell)), "cell");
Let us know if you have additional questions here.
Regards,
Deyan
Telerik by Progress
Want to build beautiful Android apps as well? Check out UI for Android which enables the same set of scenarios, allowing you to create the same great app experience on both iOS and Android.