mirror of
https://github.com/material-components/material-components-ios.git
synced 2026-02-20 08:27:32 +08:00
* chips readme components added and autogenerated a new chip readme. * readme updates. * change component name to chips. * short description was missing. https://github.com/material-components/material-components-ios/pull/3621
726 B
726 B
Create a single Chip
Swift
let chipView = MDCChipView()
chipView.titleLabel.text = "Tap me"
chipView.setTitleColor(UIColor.red, for: .selected)
chipView.sizeToFit()
chipView.addTarget(self, action: #selector(tap), for: .touchUpInside)
self.view.addSubview(chipView)
Objective-C
MDCChipView *chipView = [[MDCChipView alloc] init];
chipView.titleLabel.text = @"Tap me";
[chipView setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
[chipView sizeToFit];
[chipView addTarget:self
action:@selector(tap:)
forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:chipView];