iOS–在UILabel上加 UIButton –问为什么平面显示button在label的下面

iOS 码拜 8年前 (2016-03-27) 1056次浏览
    UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
[label setBackgroundColor:[UIColor redColor]];
[self.view addSubview:label];

UIButton * button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(20,20, 100, 64);
[button setBackgroundColor:[UIColor greenColor]];
[label addSubview:button];
[label bringSubviewToFront:button];
平面显示
iOS--在UILabel上加 UIButton --问为什么平面显示button在label的下面
实际
iOS--在UILabel上加 UIButton --问为什么平面显示button在label的下面

解决方案

15

本人刚才试了一下,还真是这样,不过本人没有计划去研究为什么,原因是这种作法违犯了HIG

15

iOS Human Interface Guidelines
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/index.html?utm_source=twitterfeed&utm_medium=twitter

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明iOS–在UILabel上加 UIButton –问为什么平面显示button在label的下面
喜欢 (0)
[1034331897@qq.com]
分享 (0)