Is this a UIButton? If it is, how is the background red done? Obviously, it is not red UIColor? Is there same tool or utility included with Xcode to allow making buttons like this?
class UIButton : UIControl. The buttons are one of the most important parts of iOS applications. Buttons are associated with the actions that are performed when the user interacts with the button. We can add the button to the iOS application programmatically or by using interface builder.
SwiftUI's button is similar to UIButton , except it's more flexible in terms of what content it shows and it uses a closure for its action rather than the old target/action system. To create a button with a string title you would start with code like this: Button("Button title") { print("Button tapped!") }
You can generate similar buttons with private class UIGlassButton
.
I saw it first here http://pastie.org/830884 by @schwa.
Run an app with this code in your iOS simulator to create a custom button (or in the device, save to $(APP)/Documents and enable iTunes file sharing).
Class theClass = NSClassFromString(@"UIGlassButton");
UIButton *theButton = [[[theClass alloc] initWithFrame:CGRectMake(10, 10, 120, 44)] autorelease];
// Customize the color
[theButton setValue:[UIColor colorWithHue:0.267 saturation:1.000 brightness:0.667 alpha:1.000] forKey:@"tintColor"];
//[theButton setTitle:@"Accept" forState:UIControlStateNormal];
[self.view addSubview:theButton];
UIGraphicsBeginImageContext(theButton.frame.size);
CGContextRef theContext = UIGraphicsGetCurrentContext();
[theButton.layer renderInContext:theContext];
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
NSData *theData = UIImagePNGRepresentation(theImage);
[theData writeToFile:@"/Users/<# your user #>/Desktop/button.png" atomically:NO];
UIGraphicsEndImageContext();
Once you obtain the png, use it as button background.
Alternatively, you can build the buttons programmatically (by Jeff Lamarche).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With