The EDSTouchButton is a custom UIButton subclass designed to provide a visually appealing touch feedback to users. It creates a cool glowing effect when tapped by animating the background color of the button.
Features
- Customizable button appearance
- Glowing animation effect on button tap
- Support for both text and image buttons
- Easy integration with existing projects
- Compatible with Objective-C and Swift
Requirements
The EDSTouchButton requires the following:
- iOS 10.0+
- Xcode 10.0+
- Swift 4.0+ or Objective-C
Installation
To install the EDSTouchButton in your project, you have multiple options:
- Using CocoaPods:
- Manual Installation:
“`ruby
# Add the following line to your Podfile
pod ‘EDSTouchButton’
“`
“`swift
import EDSTouchButton
“`
“`objc
@import EDSTouchButton;
“`
Usage
Using the EDSTouchButton is straightforward. Follow the steps below:
- Create an instance of EDSTouchButton
- Customize the button’s appearance, if desired
- Add the button to your view hierarchy
- Implement the button tap event handling
Here’s an example of how to use the EDSTouchButton in Swift:
“`swift
import EDSTouchButton
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Create an instance of EDSTouchButton
let touchButton = EDSTouchButton(frame: CGRect(x: 0, y: 0, width: 100, height: 40))
// Customize the button’s appearance
touchButton.setTitle(“Tap Me”, for: .normal)
touchButton.setTitleColor(.white, for: .normal)
touchButton.backgroundColor = .blue
// Add the button to your view hierarchy
view.addSubview(touchButton)
// Implement the button tap event handling
touchButton.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)
}
@objc func buttonTapped() {
// Handle button tap event here
print(“Button tapped!”)
}
}
“`
“`objc
@import EDSTouchButton;
@interface ViewController ()
@end
@implementation ViewController
– (void)viewDidLoad {
[super viewDidLoad];
// Create an instance of EDSTouchButton
EDSTouchButton *touchButton = [[EDSTouchButton alloc] initWithFrame:CGRectMake(0, 0, 100, 40)];
// Customize the button’s appearance
[touchButton setTitle:@”Tap Me” forState:UIControlStateNormal];
[touchButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[touchButton setBackgroundColor:[UIColor blueColor]];
// Add the button to your view hierarchy
[self.view addSubview:touchButton];
// Implement the button tap event handling
[touchButton addTarget:self action:@selector(buttonTapped) forControlEvents:UIControlEventTouchUpInside];
}
– (void)buttonTapped {
// Handle button tap event here
NSLog(@”Button tapped!”);
}
@end
“`
Note: Adjust the frame properties and visual customization according to your project requirements.
Customization
The EDSTouchButton allows you to customize its appearance to fit your design. Here are some of the customizable properties:
- backgroundColor: The background color of the button (
UIColor
) - borderColor: The border color of the button (
UIColor
) - cornerRadius: The corner radius of the button’s background (
CGFloat
) - glowColor: The glowing animation color (
UIColor
) - animationDuration: The duration of the glowing animation (
TimeInterval
)
“`swift
let touchButton = EDSTouchButton(frame: CGRect(x: 0, y: 0, width: 100, height: 40))
touchButton.backgroundColor = .blue
touchButton.borderColor = .black
touchButton.cornerRadius = 8.0
touchButton.glowColor = .yellow
touchButton.animationDuration = 0.5
“`
For more details on how to use the EDSTouchButton, please refer to the documentation.