zoukankan      html  css  js  c++  java
  • 奇数项UIBarButtonItem在UIToolbar 中的居中对齐

     1 toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
     2 
     3 toolBar.barStyle = UIBarStyleDefault;
     4 
     5  
     6 
     7 UIBarButtonItem *titleButton = [[UIBarButtonItem alloc] initWithTitle:title 
     8 
     9                                                                         style: UIBarButtonItemStylePlain 
    10 
    11                                                                        target: nil 
    12 
    13                                                                        action: nil];
    14 
    15         
    16 
    17 UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"完成" 
    18 
    19                                                                         style: UIBarButtonItemStyleDone 
    20 
    21                                                                        target: self 
    22 
    23                                                                        action: @selector(done)];
    24 
    25         
    26 
    27 //UIBarButtonItem *leftButton  = [[UIBarButtonItem alloc] initWithTitle:@"取消" 
    28 
    29 //                                                                        style: UIBarButtonItemStyleBordered 
    30 
    31 //                                                                       target: self 
    32 
    33 //                                                                       action: @selector(docancel)];
    34 
    35         
    36 
    37 UIBarButtonItem *fixedButton  = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemFlexibleSpace 
    38 
    39                                                                                       target: nil 
    40 
    41                                                                                       action: nil];
    42 
    43         
    44 
    45 NSArray *array = [[NSArray alloc] initWithObjects:fixedButton,fixedButton, titleButton,fixedButton, rightButton, nil];
    46 
    47 [toolBar setItems: array];
    48 
    49 [titleButton release];
    50 
    51 //[leftButton  release];
    52 
    53 [rightButton release];
    54 
    55 [fixedButton release];
    56 
    57 [array       release];

    对齐通过填充FlexibleSpace来实现。

  • 相关阅读:
    django学习----http协议
    线程进程和协程
    内置函数
    我所了解的递归
    函数的闭包和装饰器
    字符串的内置方法
    格式化输入输出
    逻辑运算符和操作运算符
    python流程控制
    计算机网络原理
  • 原文地址:https://www.cnblogs.com/qiezi/p/2480191.html
Copyright © 2011-2022 走看看