zoukankan      html  css  js  c++  java
  • ios中键盘处理(二)

    设置UIscrollview的背景代码

    - (UIImage *) ImageWithColor: (UIColor *) color frame:(CGRect)aFrame
    {
        UIGraphicsBeginImageContext(aFrame.size);
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextSetFillColorWithColor(context, [color CGColor]);
        CGContextFillRect(context, aFrame);
        
        UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        return theImage;
    }
       UIImage *image=[self ImageWithColor:[UIColor colorWithRed:240/255.0f green:240/255.0f blue:240/255.0f alpha:1] frame:self.view.bounds];
        
       image= [image stretchableImageWithLeftCapWidth:image.size.width*0.5f topCapHeight:image.size.height*0.5f];
        UIImageView *imageview=[[UIImageView alloc] initWithImage:image];
        [scrollview addSubview:imageview];
    
    
    动态生成控件
    //封装UILabel
    +(UILabel*)LabWithFrame:(CGRect)_rect text:(NSString*)aText textColor:(UIColor*)aColor textAlign:(NSTextAlignment)aAlign font:(UIFont*)aFont{ UILabel *lab = [[[UILabel alloc] initWithFrame:_rect] autorelease]; lab.backgroundColor = [UIColor clearColor]; if ([aText length] > 0) lab.text = aText; if (aColor) lab.textColor = aColor; if(aAlign) lab.textAlignment = aAlign; if (aFont) lab.font = aFont; return lab; }
    //文本框
    +(UITextField*)TextFieldWithFrame:(CGRect)_rect
                               target:(id)target
                                 text:(NSString*)aText
                            textColor:(UIColor*)aTextColor
                            textAlign:(NSTextAlignment)aAlign
                          placeHolder:(NSString*)holder
                            clearMode:(UITextFieldViewMode)aViewMode
    {
        UITextField *textField = [[[UITextField alloc] initWithFrame:_rect] autorelease];
        textField.backgroundColor = [UIColor clearColor];
        textField.delegate = target;
        
        if (aAlign)
            textField.textAlignment = aAlign;
        if ([aText length] > 0)
            textField.text = aText;
        if (aTextColor)
            textField.textColor = aTextColor;
        if (aViewMode)
            textField.clearButtonMode = aViewMode;
        if ([holder length] > 0)
            textField.placeholder = holder;
        textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        
        return textField;
    }
    
    
       
        CGRect viewRect=self.view.bounds;
        CGRect bRec,ftRec=self.view.bounds;
        ftRec=UIEdgeInsetsInsetRect(viewRect, UIEdgeInsetsMake(Kpadding, Kpadding, Kpadding, Kpadding));
        
        for (int i=0; i<self.mydata.count; i++) {
            
            Person *p=self.mydata[i];
            //得到每一行 ,每行50的距离分割
            CGRectDivide(ftRec, &bRec, &ftRec, 50, CGRectMinYEdge);
            
    //得到padding的巨鹿 CGRect lbRect
    =UIEdgeInsetsInsetRect(bRec, UIEdgeInsetsMake(0, 0, 0, kLbWidth)); //得到label的值 UILabel *label=[UILabel LabWithFrame:lbRect text:p.name textColor:[UIColor blackColor] textAlign:NSTextAlignmentRight font:[UIFont systemFontOfSize:12]]; [self.view addSubview:label]; [label release]; CGRect txtRect=UIEdgeInsetsInsetRect(bRec, UIEdgeInsetsMake(Kpadding, lbRect.size.width+Kpadding, 0, 0)); UITextField *txtField=[UITextField TextFieldWithFrame:txtRect target:self text:p.desc textColor:[UIColor blackColor] textAlign:NSTextAlignmentLeft placeHolder:nil clearMode: UITextFieldViewModeWhileEditing]; txtField.borderStyle=UITextBorderStyleRoundedRect; [self.view addSubview:txtField]; [txtField release]; }


    TableView背景设置

    
    
    
    
    

    UIImageView *tableBg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"XXX.png"]];
    [yourTable setBackgroundView:tableBg];
    [tableBg release];

     











  • 相关阅读:
    request.getDispatcher().forward(request,response)和response.sendRedirect()的区别
    处理get中文乱码
    在oracle里,如何取得本周、本月、本季度、本年度的第一天和最后一天的时间
    js 获取 本周、上周、本月、上月、本季度、上季度的开始结束日期
    Oracle 查询今天、昨日、本周、本月和本季度的所有记录
    CASE WHEN 及 SELECT CASE WHEN的用法
    漳州台的八边形坐标
    ubuntu16.04下下载baiduyun大文件
    ubuntu16.04下gmt5.4.1 中文支持
    ubuntu16.04下wps的安装
  • 原文地址:https://www.cnblogs.com/gcb999/p/3182432.html
Copyright © 2011-2022 走看看