Detailed cell item of action sheets. It has icon, title, and subtitle. Similar to Facebook's action menu. Similar to Facebook's action menu.
These are the example of action sheet with title only, title with icon, and title with icon and subtitle:
Download repository, then add RDDetailedActionController directory to your project.
Then import header files where you need to use the library
For objective-c, since the pod is built using Swift, we need to import the switch-to-objective-c bridge header.
#import "RDDetailedActionController-Swift.h"
And that's it. You're good to go.
For swift, you just do nothing. The controller should be available right away.
CocoaPods is a dependency manager for Objective-C and Swift, which automates and simplifies the process of using 3rd-party libraries in your projects. To install with cocoaPods, follow the "Get Started" section on CocoaPods.
platform :ios, '8.0'
use_frameworks!
pod 'RDDetailedActionController'
Then import framework where you need to use the library (since this lib is in Swift, import the swift-to-objc bridging header)
#import <RDDetailedActionController/RDDetailedActionController-Swift.h>
// OR
@import RDDetailedActionController;
And don't forget to set the Pod project's Swift Compiler to Swift 4 if you have not done it before.
import RDDetailedActionController
You can use one of these two methods for initialization:
- (nonnull instancetype)initWithTitle:(NSString * _Nullable)title
subtitle:(NSString * _Nullable)subtitle;
- (nonnull instancetype)initWithTitle:(NSString * _Nullable)title
subtitle:(NSString * _Nullable)subtitle
font:(UIFont * _Nullable)font
titleColor:(UIColor * _Nullable)titleColor;
public init(title: String?, subtitle: String?)
public init(title: String?, subtitle: String?, font: UIFont?, titleColor: UIColor?)
The first method is using default values for font and color of the action sheet title. This is the default usage to ensure consistent look and feel.
The second method is providing font and title color of the action sheet title. This method should be used if you want to specify font and color ONLY to this particular action sheet.
Or you could just using the default init and set the four properties one by one.
To add action buttons, you can call either of these methods:
- (void)addActionWithTitle:(NSString * _Nonnull)title
subtitle:(NSString * _Nullable)subtitle
icon:(UIImage * _Nullable)icon
action:(returnType (^)(RDDetailedActionView * _Nonnull))action;
- (void)addActionWithTitle:(NSString * _Nonnull)title
subtitle:(NSString * _Nullable)subtitle
icon:(UIImage * _Nullable)icon
titleColor:(UIColor * _Nullable)titleColor
subtitleColor:(UIColor * _Nullable)subtitleColor
action:(returnType (^)(RDDetailedActionView * _Nonnull))action;
- (void)addActionWithTitle:(RDDetailedActionView * _Nonnull)actionView;
public func addAction(title: String, subtitle: String?, icon: UIImage?, action: ((RDDetailedActionView)->())?)
public func addAction(title: String, subtitle: String?, icon: UIImage?, titleColor: UIColor?, subtitleColor: UIColor?, action: ((RDDetailedActionView)->())?)
public func addAction(action: RDDetailedActionView)
You can show and dismiss action sheet by calling these methods:
[detailedActionController show];
[detailedActionController hide];
detailedActionController.show()
detailedActionController.hide()
When you use the first initialization method, the action sheets are using default font and color for it's title. We can customize these values so that we can have custom font and color throughout the app.
RDDetailedActionController.defaultTitleFont = [UIFont fontWithName:@"HelveticaNeue" size:14];
RDDetailedActionController.defaultTitleColor = [UIColor blueColor];
RDDetailedActionController.defaultTitleFont = UIFont(name: "HelveticaNeue", size: 14)!
RDDetailedActionController.defaultTitleColor = .blue
So does the action button. We can set the default color of the title and subtitle.
RDDetailedActionView.defaultTitleColor = [UIColor darkGrayColor];
RDDetailedActionView.defaultSubtitleColor = [UIColor grayColor];
RDDetailedActionView.defaultTitleColor = .darkGray
RDDetailedActionView.defaultSubtitleColor = .gray
For more details try Xcode DemoSwift project or DemoObjC project and see RDDetailedActionController.swift
RDDetailedActionController is released under the MIT license. See LICENSE for details.