Code Monkey home page Code Monkey logo

ftpopovermenu_swift's Introduction

FTPopOverMenu

Twitter Carthage compatible GitHub license Version Download CocoaPods GitHub stars

Swift version of FTPopOverMenu.

FTPopOverMenu

FTPopOverMenu is a pop over menu for iOS which is maybe the easiest one to use, supports both portrait and landscape. It can show from any UIView, any UIBarButtonItem and any CGRect. Simplest APIs, enable you to change the style in one line of code.

somtimes I want to customer every cell, so I seperate the global setting, and cell setting. e.g: my PM want some menu item are show but can't tap for some reason.

ScreenShots

screenshot

Installation

Manually

  • clone this repo.
  • Simply drag and drop the '/FTPopOverMenu_Swift/FTPopOverMenu.swift' file into your project.

CocoaPods

FTPopOverMenu_Swift is available through CocoaPods. To install it, simply add the following line to your Podfile:

  • For Swift 4, please use version <= 0.1.4
  • For Swift 5, please use version >= 0.2.0
  • Big API change at 0.3.0, update at your own risk.
  • version >= 0.4.1 Version, changed the name of framework, from FTPopOverMenu_Swift to FTPopOverMenu
target 'MyApp' do
    pod 'FTPopOverMenu_Swift', '~> 0.1.4'
end

Then run a pod install inside your terminal, or from CocoaPods.app.

Usage

Customize

Do any of the following settings to set the style (Only set the ones you want to change), maybe do this when app starts or when you want it to show a different style, but remember it's global change.

    let configuration = FTConfiguration.shared
    configuration.menuRowHeight = ...
    configuration.menuWidth = ...
    configuration.textColor = ...
    configuration.textFont = ...
    configuration.tintColor = ...
    configuration.borderColor = ...
    configuration.borderWidth = ...
    configuration.textAlignment = ...
    configuration.ignoreImageOriginalColor = ...;
    // set 'ignoreImageOriginalColor' to YES, images color will be same as textColor

From SenderView, Menu Without Images.

        FTPopOverMenu.showForSender(sender: sender,
                                    with: ["Share"],
                                    done: { (selectedIndex) -> () in
                              
                                        print(selectedIndex)
        }) {
            
        }

From SenderView, Menu With Images.

        FTPopOverMenu.showForSender(sender: sender,
                                    with: ["Share"],
                                    menuImageArray: ["iconImageName"],
                                    done: { (selectedIndex) -> () in
                              
                                        print(selectedIndex)
        }) {
            
        }

From SenderFrame/NavigationItem, Menu Without Images.

        FTPopOverMenu.showFromSenderFrame(senderFrame: sender.frame,
                                          with: ["Share"],
                                          done: { (selectedIndex) -> () in
                                            
        }) {
            
        }

From SenderFrame/NavigationItem, Menu With Images.

        FTPopOverMenu.showFromSenderFrame(senderFrame: sender.frame,
                                          with: ["Share"],
                                          menuImageArray: ["iconImageName"],
                                          done: { (selectedIndex) -> () in
                                            
        }) {
            
        }

From barButtonItems .

  • First: add action with event to you barButtonItems
    @IBAction func handleAddBarButtonItem(_ sender: UIBarButtonItem, event: UIEvent) {
        
        FTPopOverMenu.showForEvent(event: event,
                                   with: ["Share"],
                                   menuImageArray: ["iconImageName"],
                                   done: { (selectedIndex) -> () in
        
        }) {
            
        }
    }

CHANGELOG

CHANGELOG

More

  • Swift version of FTPopOverMenu.
  • Logo Designed by @Tobaloidee
  • Images in the demo from https://www.iconfinder.com/iconsets/pokemon-go.
  • If you like it, or maybe wanna use it in your own projects, please give me a star.
  • Looking for another way of doing this? Take a look at my another FTPopMenu at here. It was another way of showing pop over menus, which is wrapped from UIPopoverViewController, and more genetic and more good-looking. Feel free to try it.

License

FTPopOverMenu_Swift is available under the MIT license. See the LICENSE file for more info.

ftpopovermenu_swift's People

Contributors

abdullahselek avatar chquanquan avatar dogo avatar ems305 avatar ethi1989 avatar g00m avatar ilya-iks avatar liufengting avatar mssjappjwt avatar svyatogor avatar tobaloidee avatar yanchaogan avatar yizhi996 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ftpopovermenu_swift's Issues

Using in widget

I can't get the popover menu to work in a today widget in Notification Center.

'FTConfiguration' initializer is inaccessible due to 'internal' protection level

Pod:- pod 'FTPopOverMenu_Swift', '~> 0.1.4'
OS:- Catelina
iOS:- 14+
Language:- Swift 4+

jus install the pod and try to configure with the below function I'm getting this error

func configWithMenuStyle() -> FTConfiguration {
let config = FTConfiguration()
config.backgoundTintColor = UIColor.white
config.borderColor = UIColor.lightGray
config.menuWidth = 80
config.menuSeparatorColor = UIColor.lightGray
config.menuRowHeight = 40
config.cornerRadius = 6
config.textColor = UIColor.black
config.textAlignment = NSTextAlignment.center
return config
}

** 'FTConfiguration' initializer is inaccessible due to 'internal' protection level **

FTCellConfiguration not working.

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

Will anyone please guide me why it's not working or let me know the steps to change it.
Thanks

Can I set the background color of selected menu items?

Usually when I tap on a menu item, the menu item's background color changes. But when I change the menu items' normal background color to a greyish color, the color change when selected is not that obvious. I can't take a screenshot of the selected menu item's color though. To reproduce this, set the menu's background color to d2d2d2 and observe the color change.

Logo Proposal

Good day @liufengting I am a graphic designer and an open source enthusiast..I would like to contribute to your good project by proposing a logo design for it if you allow me..I will be doing it as a gift for free to your project. I just need your permission first before i begin. Thanks and best regards!

Hoping for a positive feedback.. :)

  • Tobaloidee

似乎存在严重的内存泄漏问题

Screen Shot 2020-05-21 at 10 36 00 PM

Screen Shot 2020-05-21 at 10 35 38 PM

我使用的是 Demo App。如果点击左上角文件夹图标并关闭,重复数次,则会创建数个 FTPopOverMenuView。似乎在 Closure 中存在 Memory Cycle。

UIApplication.shared is unavailable in Catalyst (Xcode 13, iOS 15)

I just installed Xcode 13 and my app won't build due to use of UIApplication.shared.keyWindow?

The error is:
'shared' is unavailable in application extensions for Mac Catalyst: Use view controller based solutions where appropriate instead.

My app runs on iOS and mac (via Catalyst)

FTPopOverMenu is installed via SPM and is actually unused in the Catalyst version. However, because Xcode still tries to build it, I get the error and the build fails.

I'm going to try installing via CocoaPods and then not install that pod for the Catalyst build. However, I thought I'd point this out in case it becomes an issue for someone else.
It would be great if I could use FTPopOverMenu with Catalyst.

Thanks,
Joe

Text Color

Did you remove the text color property - how can we set the text color?

FTCellConfiguration not working.

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: #37 (comment)

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

How do I set the text color of the menu items?

In an old version of this pod (0.0.7), there was a property called textColor in FTConfiguration. This does not seem to be present in the version I am currently using (0.1.2). How can I set the text color?

Can't customize due to internal protection

Hey,

I'm trying to use your pod (as a framework) in my app but I can't access the shared configuration properties. I've looked down your files but I can't see any internal protected class... Any idea ?

capture d ecran 2017-01-05 a 11 25 54

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.