NSDictionary *attributes = @{NSFontAttributeName:[UIFontsystemFontOfSize:17]};
//获取button上文字
NSString *title=[_buttoningtitleForState:UIControlStateNormal];
NSLog(@"button上文字%@",title);
//获取button上文字的宽度(length 是个定义的一个全局变量)
length = [title boundingRectWithSize:CGSizeMake(320, 2000)options:NSStringDrawingUsesLineFragmentOriginattributes:attributes context:nil].size.width;
//白色动画 线
UIView *redLine =[[UIViewalloc]initWithFrame:CGRectMake(((K_SCERRN_WIDTH / 2)-length)/2, 0,length, 1)];
[redLine setBackgroundColor:[UIColor whiteColor]];
self.arrowView = redLine;
[_line addSubview:redLine];
button事件
[UIView animateWithDuration:0.25 animations:^{
_arrowView.x = ((K_SCERRN_WIDTH / 2)-length)/2;
}];
[UIView animateWithDuration:0.25 animations:^{
_arrowView.x = _buttonend.x+((K_SCERRN_WIDTH / 2)-length)/2;
}];
新闻热点
疑难解答