zoukankan      html  css  js  c++  java
  • 3.monotouch 界面布局

    1.资源图片的放置。

    布局界面的时候需要将图片放到项目中,monotouch中图片可以直接加到项目根目录下,但是图片过多时就会显的比较乱。最好的做法就是放到Resources 文件下。该文件中的图片属性必须确保Build action 为BundleResource,Resources文件夹下不可以分子文件目录存放图片。

    2.布局时,通常需要设置一个大的背景,monotouch中没有面板的概念,通常最基本的是UIView,可以用它来做分块。一个xib的顶级父容器就是UIView,由于UIView的Background在属性栏中只能设置颜色,不带有图片,所以可以选择使用一个UIImageView作为背景,设置UIImageView的大小坐标与父容器相同。如果一个界面上排列的元素过多,鼠标无法准确点到时,就需要用到Placeholders。如图所示:

    eg1:                                                             eg2:

                 

    当前页所有元素都会排列出来。

    3.使用代码添加控件到View中,例如添加按钮。

    UIImage img=UIImage.FromFile("button_top.png");
    
    UIButton btnRefresh=new UIButton ();
    //设置坐标大小
    btnRefresh.Frame=new RectangleF (700,5,95,32);
    btnRefresh.Font = UIFont.SystemFontOfSize (12);
    btnRefresh.SetBackgroundImage(img,UIControlState.Normal);
    btnRefresh.SetTitle("Refresh",UIControlState.Normal);
    btnRefresh.SetTitleColor(UIColor.White,UIControlState.Normal);
    
    //点击事件
    btnRefresh.TouchUpInside+= btnRefresh_Click;
    this.View.AddSubview(btnRefresh);
    
    void btnRefresh_Click (object sender, EventArgs e)
    {
        LoadData();
    }

    4.从View中删除控件
    btnRefresh.TouchUpInside-= btnRefresh_Click;
    btnDelete.RemoveFromSuperview();
    
    
  • 相关阅读:
    springMVC+MyBatis+Spring+maven 整合(1)
    mysql.zip免安装版配置
    5.6 循环依赖
    5.5 准备创建bean
    5.4 获取单例
    SQL Server(九)——事务
    SQL Server(七)——存储过程
    SQL Server(八)——触发器
    SQL Server(六)——索引、视图和SQL编程
    SQL Server(五)——常用函数 转
  • 原文地址:https://www.cnblogs.com/Cindys/p/2972683.html
Copyright © 2011-2022 走看看