关于button的主题对齐方式注意事项

来源:互联网 发布:淘宝平面设计接单 编辑:程序博客网 时间:2024/06/06 09:23

 UIButton*button=[UIButtonbuttonWithType:UIButtonTypeCustom];

 //button的缺省状态对其方式是居中对齐

//    UIControlContentHorizontalAlignmentCenter = 0,

//    UIControlContentHorizontalAlignmentLeft   = 1,

//    UIControlContentHorizontalAlignmentRight  = 2,

//    UIControlContentHorizontalAlignmentFill   = 3,

    button.frame=CGRectMake(100,100, 100, 100);

    button.backgroundColor=[UIColorredColor];

    [button setTitle:@"点我呀"forState:UIControlStateNormal];

    button.contentHorizontalAlignment=0;正确地设置方式

//    NSTextAlignmentLeft      = 0,    // Visually left aligned

//#if TARGET_OS_IPHONE

//    NSTextAlignmentCenter    = 1,    // Visually centered

//    NSTextAlignmentRight     = 2,

 //下面这样设置button上的主题的对齐方式是没有用的

    button.titleLabel.textAlignment=NSTextAlignmentLeft ;

    [self.viewaddSubview:button];


0 0
原创粉丝点击