一个很简陋的计算器

package com.imooc.calculator;

import java.util.ArrayList;
import java.util.Arrays;

import bsh.EvalError;
import bsh.Interpreter;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends Activity implements OnClickListener {
    Button btn_0;
    Button btn_1;
    Button btn_2;
    Button btn_3;
    Button btn_4;
    Button btn_5;
    Button btn_6;
    Button btn_7;
    Button btn_8;
    Button btn_9;

Button btn_point;// СÊýµã
    Button btn_divide;// ³ýÒÔ
    Button btn_multiply;// ³ËÒÔ
    Button btn_minus;// ¼õÈ¥
    Button btn_pluse;// ¼Ó
    Button btn_equal;// µÈÓÚ

Button btn_clear;
    Button btn_del;

EditText et_showview;
    boolean needclear;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btn_0 = (Button) findViewById(R.id.btn_0);
        btn_1 = (Button) findViewById(R.id.btn_1);
        btn_2 = (Button) findViewById(R.id.btn_2);
        btn_3 = (Button) findViewById(R.id.btn_3);
        btn_4 = (Button) findViewById(R.id.btn_4);
        btn_5 = (Button) findViewById(R.id.btn_5);
        btn_6 = (Button) findViewById(R.id.btn_6);
        btn_7 = (Button) findViewById(R.id.btn_7);
        btn_8 = (Button) findViewById(R.id.btn_8);
        btn_9 = (Button) findViewById(R.id.btn_9);
        btn_point = (Button) findViewById(R.id.btn_point);// СÊýµã
        btn_divide = (Button) findViewById(R.id.btn_divide);// ³ýÒÔ
        btn_multiply = (Button) findViewById(R.id.btn_multiply);// ³ËÒÔ
        btn_minus = (Button) findViewById(R.id.btn_minus);// ¼õÈ¥
        btn_pluse = (Button) findViewById(R.id.btn_pluse);// ¼Ó
        btn_equal = (Button) findViewById(R.id.btn_equal);// µÈÓÚ

btn_clear = (Button) findViewById(R.id.btn_clear);
        btn_del = (Button) findViewById(R.id.btn_del);
        et_showview = (EditText) findViewById(R.id.et_showview);

btn_0.setOnClickListener(this);
        btn_1.setOnClickListener(this);
        btn_2.setOnClickListener(this);
        btn_3.setOnClickListener(this);
        btn_4.setOnClickListener(this);
        btn_5.setOnClickListener(this);
        btn_6.setOnClickListener(this);
        btn_7.setOnClickListener(this);
        btn_8.setOnClickListener(this);
        btn_9.setOnClickListener(this);

btn_point.setOnClickListener(this);
        btn_divide.setOnClickListener(this);
        btn_multiply.setOnClickListener(this);
        btn_minus.setOnClickListener(this);
        btn_pluse.setOnClickListener(this);
        btn_equal.setOnClickListener(this);

btn_clear.setOnClickListener(this);
        btn_del.setOnClickListener(this);
    }

@Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        String str = et_showview.getText().toString();
        switch (v.getId()) {
        case R.id.btn_0:
        case R.id.btn_1:
        case R.id.btn_2:
        case R.id.btn_3:
        case R.id.btn_4:
        case R.id.btn_5:
        case R.id.btn_6:
        case R.id.btn_7:
        case R.id.btn_8:
        case R.id.btn_9:
        case R.id.btn_point:
            if(needclear){
                str = "";
                et_showview.setText("");
            }
            et_showview.setText(str + ((Button) v).getText());
            break;
        case R.id.btn_pluse:
        case R.id.btn_minus:
        case R.id.btn_multiply:
        case R.id.btn_divide:
            if(needclear){
                et_showview.setText("");
            }
            et_showview.setText(str +" "+((Button) v).getText()+" ");
            break;
        case R.id.btn_equal:
            getResult();
            break;
        case R.id.btn_del:
            if (str != null && !str.equals("")) {
                et_showview.setText(str.substring(0, str.length() - 1));
            }
            break;
        case R.id.btn_clear:
            et_showview.setText("");
            break;
        }
    }

/**
     * »ñÈ¡¼ÆËã½á¹û
     */
    private void getResult() {
        needclear = true;
        String exp = et_showview.getText().toString();
        double r = 0;
        int space = exp.indexOf(‘ ‘);//ÓÃÓÚËÑË÷¿Õ¸ñλÖÃ
        String s1 = exp.substring(0, space);//s1ÓÃÓÚ±£´æµÚÒ»¸öÔËËãÊý
        String op = exp.substring(space + 1, space + 2);//opÓÃÓÚ±£´æÔËËã·û
        String s2 = exp.substring(space + 3);//s2ÓÃÓÚ±£´æµÚ¶þ¸öÔËËãÊý
        double arg1 = Double.parseDouble(s1);//½«ÔËËãÊý´Óstringת»»ÎªSingle
        double arg2 = Double.parseDouble(s2);
        if(op.equals("£«")){
             r = arg1 + arg2;
        }else if(op.equals("£­")){
            r = arg1 - arg2;
        }else if(op.equals("¡Á")){
             r = arg1 * arg2;
        }else if(op.equals("¡Â")){
             if (arg2 == 0)
             {
                r=0;
             }
             else
             {
                 r = arg1 / arg2;
             }
        }       
        if(!s1.contains(".")&&!s2.contains(".")){
            int result = (int)r;
            et_showview.setText(result+"");
        }else{
            et_showview.setText(r+"");
        }
    }
//
//    /***
//     * @param exp
//     *            ËãÊý±í´ïʽ
//     * @return ¸ù¾Ý±í´ïʽ·µ»Ø½á¹û
//     */
//    private String getRs(String exp) {
//        Interpreter bsh = new Interpreter();
//        Number result = null;
//        try {
//            exp = filterExp(exp);
//            result = (Number) bsh.eval(exp);
//        } catch (EvalError e) {
//            e.printStackTrace();
//            return "0";
//        }
//        return result.doubleValue() + "";
//    }
//
//    /**
//     * @param exp
//     *            ËãÊý±í´ïʽ
//     * @return ÒòΪ¼ÆËã¹ý³ÌÖÐ,È«³ÌÐèÒªÓÐСÊý²ÎÓë.
//     */
//    private String filterExp(String exp) {
//        String num[] = exp.split("");
//        String temp = null;
//        double dtemp = 0 ;
//        String str_temp="";
//        for (int i = 0; i < num.length; i++) {
//            temp = num[i];
//            
//            if (temp.equals("+") || temp.equals("-") || temp.equals("¡Á")
//                    || temp.equals("¡Â")) {
//                if(dtemp==0){
//                dtemp=Double.parseDouble(str_temp);
//                }
//                
//                str_temp="";
//            }else{
//                str_temp=str_temp+temp;
//            }
//        }
//
//        int begin = 0, end = 0;
//        for (int i = 1; i < num.length; i++) {
//            temp = num[i];
//            if (temp.matches("[+-/()*]")) {
//                if (temp.equals("."))
//                    continue;
//                end = i - 1;
//                temp = exp.substring(begin, end);
//                if (temp.trim().length() > 0 && temp.indexOf(".") < 0)
//                    num[i - 1] = num[i - 1] + ".0";
//                begin = end + 1;
//            }
//        }
//        return Arrays.toString(num).replaceAll("[\\[\\], ]", "");
//    }
}

package com.imooc.calculator;

import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

public class ExpressionUtil {
    public double eval(String exp) {
        List<String> list = infixExpToPostExp(exp+"#");
        return doEval(list);
    }

    private double doEval(List<String> list) {
        Stack<String> stack = new Stack<String>();
        String element;
        double n1, n2, result;
        try {
            for (int i = 0; i < list.size(); i++) {
                element = list.get(i);
                if (isOperator(element)) {
                    n1 = Double.parseDouble(stack.pop());
                    n2 = Double.parseDouble(stack.pop());
                    result = doOperate(n2, n1, element);
                    stack.push(new Double(result).toString());
                } else {
                    stack.push(element);
                }
            }
            return Double.parseDouble(stack.pop());
        } catch (RuntimeException e) {
            throw new IllegalExpressionException(e.getMessage());
        }
    }
    private double doOperate(double n1, double n2, String operator) {
        if (operator.equals("+"))
            return n1 + n2;
        else if (operator.equals("-"))
            return n1 - n2;
        else if (operator.equals("*"))
            return n1 * n2;
        else
            return n1 / n2;
    }

    private boolean isOperator(String str) {
        return str.equals("+") || str.equals("-") || str.equals("*")
                || str.equals("/");
    }

    private List<String> infixExpToPostExp(String exp) {
        List<String> postExp = new ArrayList<String>();
        StringBuffer numBuffer = new StringBuffer();
        Stack<Character> opStack = new Stack<Character>();
        char ch, preChar;
        opStack.push(‘#‘);
        try {
            for (int i = 0; i < exp.length();) {
                ch = exp.charAt(i);
                switch (ch) {
                case ‘+‘:
                case ‘-‘:
                    if(i-1<0){
                        numBuffer.append(ch);
                        ch = exp.charAt(++i);
                        break;
                    }else{
                        char c = exp.charAt(i-1);
                        if(!Character.isDigit(c)){
                            numBuffer.append(ch);
                            ch = exp.charAt(++i);
                            break;
                        }
                    }
                case ‘*‘:
                case ‘/‘:
                    preChar = opStack.peek();
                    while (priority(preChar) >= priority(ch)) {
                        postExp.add("" + preChar);
                        opStack.pop();
                        preChar = opStack.peek();
                    }
                    opStack.push(ch);
                    i++;
                    break;
                case ‘(‘:
                    opStack.push(ch);
                    i++;
                    break;
                case ‘)‘:
                    char c = opStack.pop();
                    while (c != ‘(‘) {
                        postExp.add("" + c);
                        c = opStack.pop();
                    }
                    i++;
                    break;
                case ‘#‘:
                    char c1;
                    while (!opStack.isEmpty()) {
                        c1 = opStack.pop();
                        if (c1 != ‘#‘)
                            postExp.add("" + c1);
                    }
                    i++;
                    break;
                case ‘ ‘:
                case ‘\t‘:
                    i++;
                    break;
                default:
                    if (‘.‘==ch || Character.isDigit(ch)) {
                        while (Character.isDigit(ch)) {
                            numBuffer.append(ch);
                            ch = exp.charAt(++i);
                        }
                        if(‘.‘==ch){
                            numBuffer.append(‘.‘);
                            ch = exp.charAt(++i);
                        }else{
                            postExp.add(numBuffer.toString());
                            numBuffer = new StringBuffer();
                        }
                    } else {
                        throw new IllegalExpressionException("illegal operator");
                    }
                }
            }
        } catch (RuntimeException e) {
            throw new IllegalExpressionException(e.getMessage());
        }
        return postExp;
    }

    private int priority(char op) {
        switch (op) {
        case ‘+‘:
        case ‘-‘:
            return 1;
        case ‘*‘:
        case ‘/‘:
            return 2;
        case ‘(‘:
        case ‘#‘:
            return 0;
        }
        throw new IllegalExpressionException("Illegal operator");
    }

    public static void main(String[] args) {
        System.out.println("AB+AB-BC+ABC*DAB+AB".replaceAll("\\bAB\\b", "1"));
        ExpressionUtil eval = new ExpressionUtil();
        double result = eval.eval("0/3#");
        System.out.println(result);
    }

    class IllegalExpressionException extends RuntimeException {
        private static final long serialVersionUID = 1L;
        public IllegalExpressionException() {

        }
        public IllegalExpressionException(String info) {
            super(info);
        }
    }
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <EditText
        android:layout_width="fill_parent"
        android:layout_height="60dip"
        android:background="@drawable/whitebg"
        android:editable="false"
        android:id="@+id/et_showview"
        android:gravity="bottom|right"
        android:textSize="20sp" />

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginTop="20dip"
        android:gravity="center_horizontal"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:orientation="horizontal" >

            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                android:id="@+id/btn_clear"
                android:background="@drawable/white_btn_selector"
                android:text="C" />

            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_marginLeft="10dip"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                android:id="@+id/btn_del"
                android:background="@drawable/white_btn_selector"
                android:text="DEL" />

            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_marginLeft="10dip"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                android:id="@+id/btn_divide"
                android:background="@drawable/white_btn_selector"
                android:text="÷" />

            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_marginLeft="10dip"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                 android:id="@+id/btn_multiply"
                android:background="@drawable/white_btn_selector"
                android:text="×" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:gravity="center_horizontal"
            android:orientation="horizontal" >

            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                 android:id="@+id/btn_7"
                android:background="@drawable/white_btn_selector"
                android:text="7" />

            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_marginLeft="10dip"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                 android:id="@+id/btn_8"
                android:background="@drawable/white_btn_selector"
                android:text="8" />

            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_marginLeft="10dip"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                android:id="@+id/btn_9"
                android:background="@drawable/white_btn_selector"
                android:text="9" />

            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_marginLeft="10dip"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                android:id="@+id/btn_minus"
                android:background="@drawable/white_btn_selector"
                android:text="-" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:gravity="center_horizontal"
            android:orientation="horizontal" >

            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                android:id="@+id/btn_4"
                android:background="@drawable/white_btn_selector"
                android:text="4" />

            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_marginLeft="10dip"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                android:id="@+id/btn_5"
                android:background="@drawable/white_btn_selector"
                android:text="5" />

            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_marginLeft="10dip"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                 android:id="@+id/btn_6"
                android:background="@drawable/white_btn_selector"
                android:text="6" />

            <Button
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_marginLeft="10dip"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                android:id="@+id/btn_pluse"
                android:background="@drawable/white_btn_selector"
                android:text="+" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:gravity="center_horizontal"
            android:orientation="horizontal" >

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical" >

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >

                    <Button
                        android:layout_width="60dp"
                        android:layout_height="60dp"
                        android:gravity="bottom|right"
                        android:paddingBottom="10dp"
                        android:paddingRight="10dp"
                        android:textSize="20sp"
                        android:id="@+id/btn_1"
                        android:background="@drawable/white_btn_selector"
                        android:text="1" />

                    <Button
                        android:layout_width="60dp"
                        android:layout_height="60dp"
                        android:layout_marginLeft="10dip"
                        android:gravity="bottom|right"
                        android:paddingBottom="10dp"
                        android:paddingRight="10dp"
                        android:textSize="20sp"
                        android:id="@+id/btn_2"
                        android:background="@drawable/white_btn_selector"
                        android:text="2" />

                    <Button
                        android:layout_width="60dp"
                        android:layout_height="60dp"
                        android:layout_marginLeft="10dip"
                        android:gravity="bottom|right"
                        android:paddingBottom="10dp"
                        android:paddingRight="10dp"
                        android:textSize="20sp"
                        android:id="@+id/btn_3"
                        android:background="@drawable/white_btn_selector"
                        android:text="3" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dip"
                    android:orientation="horizontal" >

                    <Button
                        android:layout_width="130dp"
                        android:layout_height="60dp"
                        android:gravity="bottom|right"
                        android:paddingBottom="10dp"
                        android:paddingRight="10dp"
                        android:textSize="20sp"
                        android:id="@+id/btn_0"
                        android:background="@drawable/white_btn_selector"
                        android:text="0" />

                    <Button
                        android:layout_width="60dp"
                        android:layout_height="60dp"
                        android:layout_marginLeft="10dip"
                        android:gravity="bottom|right"
                        android:paddingBottom="10dp"
                        android:paddingRight="10dp"
                        android:text="."
                        android:id="@+id/btn_point"
                        android:background="@drawable/white_btn_selector"
                        android:textSize="20sp"/>
                </LinearLayout>
            </LinearLayout>

            <Button
                android:layout_width="60dip"
                android:layout_height="130dip"
                android:layout_marginLeft="10dip"
                android:gravity="bottom|right"
                android:paddingBottom="10dp"
                android:paddingRight="10dp"
                android:textSize="20sp"
                android:id="@+id/btn_equal"
                android:background="@drawable/orange_btn_selector"
                android:text="=" />
        </LinearLayout>
    </LinearLayout>

</LinearLayout>
时间: 2024-08-10 21:16:14

一个很简陋的计算器的相关文章

很不错的一个叫初学者做计算器的视屏http://www.56.com/redian/MTM0OTg4Mw/ODE2OTQzNjU.html

如题----------------链接在题目中! 这里不能添加! 很不错的一个叫初学者做计算器的视屏http://www.56.com/redian/MTM0OTg4Mw/ODE2OTQzNjU.html

kotlin和vertx和mongo写的一个服务器验证登陆功能(很简陋)

包结构长这个样子: server包:(服务器相关配置) HttpServer:用ver.x创建了一个http服务器,把接收到的req请求传入RPCRequest中: RPCRequest:解析请求body内容,把信息保存为M(类名) A(方法名) P(参数),同时还拥有invoke()方法,根据m.a.p的数据用反射调用方法. RPCResponse:没写,用来保存响应信息的. controller包:(将所有需要被远程调用的方法保存到内容中,加快调用时遍历查询方法的响应速度) MethodMa

类实现一个简单的日期计算器

作为一个程序员,对于时间的概念已经退化到了三岁小孩水平,常常会醉心于写一个程序忘记了时间,一个下午,一天,甚至一个星期就过去了.对于一个刚入程序员大门的我来说,时光真的是匆匆溜走,所以经常会百度一个日期计数器,算今天到那些特别的日子还有多少天.用多了后就觉得现在储备的编程知识可以去实现一个简单的日期计算器了.所以就写了这篇博客给大家分享一下. 首先,得设计这个日期类,一个日期类应该具有私有数据成员应该有年Year,月month,日day.在这我们就不精确到时分秒了. #pragma once #

设计一个一百亿的计算器

.补码(负数在计算机中的存储) .百亿计算器 负数在计算机中以补码的形式存储.负数的补码表示方法是:将负数表示成二进制原码(负数最高位是1,正数最高位是0)然后将原码取反(1变0,0变1),即反码,将反码加1(最后一位上加1),即转化为补码.如用八位二进制表示-5,第一步,原码10000101,反码01111010,加1变为补码:01111011 首先要明白这道题目的考查点是什么,一是大家首先要对计算机原理的底层细节要清楚.要知道加减法的位运算原理和知道计算机中的算术运算会发生越界的情况,二是要

一个很实用的前端框架Zui

杰哥给我推荐了一个很有用的前端框架-Zui,我看着觉得很神奇的,因为有很多我都不懂.在这里分享总结一下.首先,这是一个中国自己开发的框架,比起很多外国的框架来说,有很详细的API,而且是全中文的,不需要再经过其他人的翻译了.然后,它的内容十分丰富,很系统的分为了:基础,控件,组件,JS插件,视图几大块:而且使用起来,只需要导入js,在适当的地方加上正确的class类就可以了.对于,没有什么js基础的人,也是十分容易上手的.下面我就大体的介绍一下它的各个模块的功能.基础:基础里面我觉得很有用的主要

第一次作业:假装这里有一个很响亮的标题

---恢复内容开始--- 一.结缘计算机 缘分可以说是一个很奇妙的东西,喜欢一件事物往往从对它的美好幻想开始.相信许多人想到计算机都会将它与玩游戏联系在一起,对于我却不然,在我看来编程是一个创造的过程--这就是我对于计算机最初的美好幻想.试想通过编写一些代码便能够实现自己心中所想,这难道不是一件令人兴奋的事吗?它执行你的指令,完成你的任务,实现你的想法,这在当时是对我非常有吸引力的,于是我第一志愿便填报了计算机专业. 你认为你的条件如何?其实我并不知道这个问题应该如何回答,物质条件?素质方面?条

Go map中一个很重要的特性

先看一段代码: func main() { m := make(map[int]string) m[1] = "a" m[2] = "b" m[3] = "c" for k, v := range m { fmt.Println(k, v) } fmt.Println("-----------------") mm := make(map[int]string) mm[1] = "a" mm[2] = &q

一个很奇怪的问题

先来看看我的一段代码: 1 ArrayList<Integer> array = new ArrayList<Integer>(); 2 3 for(int i = 0;i<100;i++){ 4 array.add(i); 5 } 6 for(int i=0;i<array.size();i++){ 7 // array.remove(new Integer(i)); 8 array.remove(i); 9 } 你觉得这样能不能把array里面的东西都删除呢? 输出

UIViewAdditions(一个很方便使用的工具类吧)

我们在工程中,或多或少的要修改控件的坐标-宽度-高度,于是,经常性的见到大家self.view.frame.origin.x,self.view.frame.size.width.........相当的麻烦,在这里向大家推荐一个比较好的工具类,是UIView的类目,它里面对于求坐标,求高度什么的做了封装,很方便大家调用. @下载链接:点击这里 @.h #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @interfa