FTPopOverMenu_Swift icon indicating copy to clipboard operation
FTPopOverMenu_Swift copied to clipboard

FTCellConfiguration not working.

Open KuldeepAIP opened this issue 3 years ago • 2 comments

I want to change text color and font. For that i have tried below code but it's not working.

let cellConfiguration = FTCellConfiguration()
cellConfiguration.textColor = .black
cellConfiguration.textFont = UIFont.init(name: Fonts.AvenirRegular, size: 14.0)!
cellConfiguration.textAlignment = .left
        
var cellConfigurationArray: [FTCellConfiguration]?
cellConfigurationArray?.append(cellConfiguration)
        
FTPopOverMenu.showForSender(sender: sender, with: activeEmployeeOption, menuImageArray: [], cellConfigurationArray: cellConfigurationArray, done: { (selectedIndex) -> () in
    print(selectedIndex)
})

No crash with above code but color & font not working.

OR

FTPopOverMenu.showForSender(sender: sender, with: activeEmployeeOption, menuImageArray: [], cellConfigurationArray: [cellConfiguration], done: { (selectedIndex) -> () in
     print(selectedIndex)
})

If i use above line of code then app getting crash with Fatal error.

Fatal error: Index out of range: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-1103.2.25.8/swift/stdlib/public/core/ContiguousArrayBuffer.swift, line 444

i also tried this: https://github.com/liufengting/FTPopOverMenu_Swift/issues/37#issuecomment-675218926

but it returns me an error like : 'FTConfiguration' initializer is inaccessible due to 'internal' protection level

i am using pod 'FTPopOverMenu_Swift', '~> 0.2.0'.

KuldeepAIP avatar Aug 19 '20 04:08 KuldeepAIP

Did you ever get this to work? I'm seeing the same issue.

lukeirvin avatar Sep 17 '20 18:09 lukeirvin

@lukeirvin , yes it worked. you can try this.

Remove pod and import FTPopOverMenu_Swift folder in your project manually.

Then you need to define configuration

func configWithMenuStyle() -> FTConfiguration {
    let config = FTConfiguration()
    config.backgoundTintColor = UIColor.white
    config.borderColor = UIColor.lightGray
    config.globalShadow = true
    config.shadowAlpha = 0.05
    config.menuWidth = 110
    config.menuSeparatorColor = UIColor.clear
    config.menuRowHeight = 40
    config.cornerRadius = 2
    config.textColor = Colors.bottomTabNormalColor
    config.textAlignment = .left
    config.textFont = UIFont.init(name: Fonts.AvenirDemi, size: 16.0)!
    config.borderColor = UIColor.clear
    config.borderWidth = 0.0
    return config
}

You can use this code from where you want to show it.

@IBAction func btnMoreTapped(_ sender: UIButton) {
    FTPopOverMenu.showForSender(sender: sender, with: ["Settings", "Delete"], menuImageArray: [], popOverPosition: .automatic, config: self.configWithMenuStyle(), done: { (selectedIndex) in
        if selectedIndex == 0 {
            print("First")
        } else if selectedIndex == 1 {
            print("Second")
        }
    }, cancel: {
        print("cancel")
    })
}

Try this

KuldeepAIP avatar Sep 23 '20 06:09 KuldeepAIP