- (UIButton*)searchBarButton{
if (_searchBarButton == nil) {
_searchBarButton = [UIButton buttonWithType:UIButtonTypeCustom];
_searchBarButton.backgroundColor = [UIColor whiteColor];
_searchBarButton.layer.cornerRadius = 8;
_searchBarButton.layer.masksToBounds = YES;
/*! 字体其他 */
NSMutableAttributedString * attributedText = [[NSMutableAttributedString alloc] initWithString:@"A/B/C"];
attributedText.yy_alignment = NSTextAlignmentLeft;
attributedText.yy_font = [UIFont fontWithName:DSLFONT size:13];
attributedText.yy_color = [UIColor grayColor];
NSMutableAttributedString *attachment = nil;
UIFont *font = [UIFont fontWithName:DSLFONT size:13];
UIImageView*playVice = [UIImageView new];
playVice.image = [UIImage imageNamed:@"MianSearch"];
playVice.size = CGSizeMake(10, 10);
attachment = [NSMutableAttributedString yy_attachmentStringWithContent:playVice contentMode:UIViewContentModeScaleAspectFill attachmentSize:playVice.size alignToFont:font alignment:YYTextVerticalAlignmentTop];
[attributedText insertAttributedString:attachment atIndex:0];
[_searchBarButton setAttributedTitle:attributedText forState:UIControlStateNormal];
[_searchBarButton addTarget:self action:@selector(searchBarButtonButtonAction) forControlEvents:UIControlEventTouchUpInside];
}
return _searchBarButton;
}
我想实现这种效果,
但是以上代码无法实现,但是我没有找到问题所在,恳请帮助,非常感谢。
使用以上代码,多次尝试无效果。非常感谢。