---
title: "多个UIButtion写在UIScrowView中调用同一个点击事件"
author: "caoyudong"
date: "2014-12-30T10:56:02Z"
tags: []
categories: ["移动开发"]
slug: "uibuttion-uiscrowview"
draft: false
lastmod: "2014-12-30T11:00:24Z"
id: 2171104
url: "https://cydd.iteye.com/blog/2171104"
---

UIView:
-(void)creatButton:(id)target :(SEL)sel
{
    for (int i=0; i<3; i++)
    {
    
    btn=initWithFrame:CGRectMake(i*130, 0, 100, 30)];
        btn.tag=i;
        
        switch (i)
        {
            case 0:
                ;
                 forState:UIControlStateNormal];
                ;

                break;
            case 1:
                ;
                 forState:UIControlStateNormal];
                ;

                break;
            case 2:
                ;
                 forState:UIControlStateNormal];
                ;

                break;
            default:
                break;
        }
        ;

    }
}

UIViewController:
-(void)click:(id)sender
{
    UIButton *button = (UIButton *)sender;
    if (button.tag==0)
    scrowView.scrow.contentOffset=CGPointMake(0, 0);//点击按钮，改变UIScrowView内容的起点坐标，形成滑动效果
    if (button.tag==1)
    scrowView.scrow.contentOffset=CGPointMake(self.view.frame.size.width, 0);
}