我想在目标c 中以编程方式设计UIView
/ UILabel
这样的图像。特别是中间的边缘。有人可以帮忙吗?
目前我有:
UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.tabPosition.x,self.tabPosition.y,120,20)]; //or whatever size you need
myLabel.center = self.tabPosition;
[myLabel setFont:[UIFont systemFontOfSize:12]];
myLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.6f];
myLabel.textColor = [UIColor whiteColor];
myLabel.textAlignment = NSTextAlignmentCenter;
myLabel.text = [NSString stringWithFormat:@"%@ %@",data.user.firstName,data.user.lastName] ;
myLabel.tag = indexPath.row;
myLabel.userInteractionEnabled = YES;
UIPanGestureRecognizer *gesture = [[UIPanGestureRecognizer alloc]
initWithTarget:self
action:@selector(labelDragged:)] ;
[myLabel addGestureRecognizer:gesture];
[self.picture addSubview:myLabel];
答案 0 :(得分:0)
你需要一个像你一样的小图像。
设置UIImageview的拉伸属性,使其按您设置文本大小和边缘将保持在中间(refer this link)
答案 1 :(得分:0)