DMPagerViewController icon indicating copy to clipboard operation
DMPagerViewController copied to clipboard

Changing Icon

Open rjburdish opened this issue 10 years ago • 1 comments

The following is in swift

Is there a way to programatically change the icon from one image to another. (I.E an active image is the word "Search" and the inactive is a picture of a magnifying glass)

I am successfully creating the view controller with the text icon by:

searchViewController.pagerObj = DMPagerNavigationBarItem.newItemWithText(NSAttributedString(string: "Search", attributes: textAttributes! as [NSObject : AnyObject]), andIcon:UIImage(named: nil))

I am successfully determining when my searchViewController becomes active/inactive however I am unable to change the icon using:

searchViewController.pagerObj = DMPagerNavigationBarItem.newItemWithText(NSAttributedString(string: "", attributes: textAttributes! as [NSObject : AnyObject]), andIcon:UIImage(named: "searchImage"))

rjburdish avatar Aug 21 '15 04:08 rjburdish

I was able to solve this and get the icon changing by initializing the viewcontroller with the following code:

searchViewController.pagerObj = DMPagerNavigationBarItem.newItemWithText(NSAttributedString(string: "Search", attributes: textAttributes! as [NSObject : AnyObject]), andIcon:UIImage(named: "searchImage")) searchViewController.pagerObj.renderingMode = DMPagerNavigationBarItemMode.OnlyText

then when the view controller goes active: searchViewController.pagerObj.renderingMode = DMPagerNavigationBarItemMode.OnlyText

then when the view controller goes inactive: searchViewController.pagerObj.renderingMode = DMPagerNavigationBarItemMode.OnlyImage

rjburdish avatar Aug 21 '15 04:08 rjburdish