Change background color of suggestion cells

2 posts, 0 answers
  1. Armando
    Armando avatar
    4 posts
    Member since:
    Nov 2015

    Posted 19 Jul Link to this post

    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?.

  2. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 22 Jul Link to this post

    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:

    /**
     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
  3. DevCraft banner
Back to Top