material-components_materia.../components/Buttons/examples/ButtonsContentEdgeInsetsExample.m
featherless 2414525074
[Buttons] Replace MDCFlatButton with MDCButton + text themer in content edge insets example. (#3583)
Also fixes a bug where the button was being initialized as a system button instead of as a custom button. This was affecting the highlighted text state.

Pivotal story: https://www.pivotaltracker.com/story/show/157189341

Before (normal / highlighted):
![simulator screen shot - iphone se - 2018-04-30 at 09 21 34](https://user-images.githubusercontent.com/45670/39429179-18130c08-4c58-11e8-972a-b96dd827ee26.png) ![simulator screen shot - iphone se - 2018-04-30 at 09 21 36](https://user-images.githubusercontent.com/45670/39429181-193b0ff4-4c58-11e8-8dab-dcdfcf86a7cf.png)

After (normal / highlighted):
![simulator screen shot - iphone se - 2018-04-30 at 09 21 03](https://user-images.githubusercontent.com/45670/39429211-2e171710-4c58-11e8-95e6-07eb614857c8.png) ![simulator screen shot - iphone se - 2018-04-30 at 09 21 04](https://user-images.githubusercontent.com/45670/39429215-30bde2c8-4c58-11e8-882a-e585da609684.png)
2018-04-30 12:48:38 -04:00

74 lines
2.4 KiB
Objective-C

/*
Copyright 2017-present the Material Components for iOS authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#import <UIKit/UIKit.h>
#import "MaterialButtons.h"
#import "MaterialButtons+ButtonThemer.h"
@interface ButtonsContentEdgeInsetsExample : UIViewController
@property(weak, nonatomic) IBOutlet MDCButton *textButton;
@property(weak, nonatomic) IBOutlet MDCButton *containedButton;
@property(weak, nonatomic) IBOutlet MDCFloatingButton *floatingActionButton;
@property(weak, nonatomic) IBOutlet UISwitch *inkBoundingSwitch;
@end
@implementation ButtonsContentEdgeInsetsExample
#pragma mark - Catalog by Convention
+ (NSArray<NSString *> *)catalogBreadcrumbs {
return @[ @"Buttons", @"Buttons (Content Edge Insets)" ];
}
+ (NSString *)catalogStoryboardName {
return @"ButtonsContentEdgeInsets";
}
+ (BOOL)catalogIsPrimaryDemo {
return NO;
}
#pragma mark - UIViewController
- (void)viewDidLoad {
[super viewDidLoad];
MDCButtonScheme *buttonScheme = [[MDCButtonScheme alloc] init];
[MDCContainedButtonThemer applyScheme:buttonScheme toButton:self.containedButton];
[MDCTextButtonThemer applyScheme:buttonScheme toButton:self.textButton];
self.textButton.contentEdgeInsets = UIEdgeInsetsMake(64, 64, 0, 0);
self.containedButton.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 64, 64);
[self.floatingActionButton setContentEdgeInsets:UIEdgeInsetsMake(40, 40, 0, 0)
forShape:MDCFloatingButtonShapeDefault
inMode:MDCFloatingButtonModeNormal];
[self updateInkStyle:self.inkBoundingSwitch.isOn ? MDCInkStyleBounded : MDCInkStyleUnbounded];
}
- (void)updateInkStyle:(MDCInkStyle)inkStyle {
self.textButton.inkStyle = inkStyle;
self.containedButton.inkStyle = inkStyle;
self.floatingActionButton.inkStyle = inkStyle;
}
- (IBAction)didChangeInkStyle:(UISwitch *)sender {
[self updateInkStyle:sender.isOn ? MDCInkStyleBounded : MDCInkStyleUnbounded];
}
@end