网赌平台哪个信誉好iOS自定义alertView,继承自UIView,可以添加子视图,标题图片+文字

iOS自定义alertView,继承自UIView,可以添加子视图,标题图片+文字

自定义alertView,继承自UIView,可以在消息区域添加子视图:addCustomerSubview

标题可以有图片+文字构成, 只支持两个按钮操作

// – 在需要alert的控制器调用 alertView show 方法

CustomAlertView *alertView = [[CustomAlertView alloc] initWithTitle:@"提示"
                                                        message:@"dylan_lwb_"
                                                       delegate:self
                                              cancelButtonTitle:@"确定"
                                              otherButtonTitles: nil];
//    [alertView addCustomerSubview:myView];
    [alertView show];
    [alertView release];

// - 代理方法
-(void)alertView:(CustomAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{

}
-(void)alertViewClosed:(CustomAlertView *)alertView
{

}
-(void)willPresentCustomAlertView:(UIView *)alertView
{

}

// – 在项目里创建一个CustomAlertView分类, 把下边代码全部复制过去,
不要管干嘛的

#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 5549)
#define NS_REQUIRES_NIL_TERMINATION __attribute__((sentinel(0,1)))
#else
#define NS_REQUIRES_NIL_TERMINATION __attribute__((sentinel))
#endif

#define SCREEN_WIDTH    [[UIScreen mainScreen] bounds].size.width
#define SCREEN_HEIGHT   [[UIScreen mainScreen] bounds].size.height
#define RGBA_COLOR(r, g, b, a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
#define kBCAlertViewPresentNotify   @"kBCAlertViewPresentNotify"  //alertview present notify

#import 
#import 

@class CustomAlertView;

@protocol MBAlertViewDelegate 

@optional

// - 代理方法
-(void)alertView:(CustomAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;
-(void)alertViewClosed:(CustomAlertView *)alertView;
-(void)willPresentCustomAlertView:(UIView *)alertView;

// - 隐藏实用类弹出键盘
- (void)hideCurrentKeyBoard;

@end

@interface CustomAlertView : UIView {
}

@property (nonatomic, assign) id  delegate;
@property (nonatomic, assign) BOOL           isNeedCloseBtn;  // - 左上角带叉叉按钮
@property (nonatomic, retain) NSString       *title;
@property (nonatomic, retain) NSString       *message;
@property (nonatomic, retain) UIView         *backView;
@property (nonatomic, retain) UIView         *titleBackgroundView;
@property (nonatomic, retain) UILabel        *titleLabel;
@property (nonatomic, retain) UIImageView    *titleIcon;
@property (nonatomic, retain) NSMutableArray *customerViewsToBeAdd;

- (id)initWithTitle:(NSString*)title message:(NSString*)message delegate:(id)delegate cancelButtonTitle:(NSString*)cancelButtonTitle otherButtonTitles:(NSString*)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION;

-(void)initTitle:(NSString*)title message:(NSString*)message delegate:(id)del cancelButtonTitle:(NSString*)cancelBtnTitle otherButtonTitles:(NSString*)otherBtnTitles, ...NS_REQUIRES_NIL_TERMINATION;

- (void) show ;

// - 在alertview中添加自定义控件
- (void)addCustomerSubview:(UIView *)view;

+ (void)exChangeOut:(UIView *)changeOutView dur:(CFTimeInterval)dur;

+ (CustomAlertView *)defaultAlert;

@end








#import "CustomAlertView.h"
@interface CustomAlertView()

{
    BOOL _isShow;
}
@property (nonatomic, retain) NSString       *cancelButtonTitle;
@property (nonatomic, retain) NSMutableArray *otherButtonTitles;

@end

@implementation CustomAlertView

static const CGFloat mWidth  = 290;
static const CGFloat mHeight = 180;
static const CGFloat mMaxHeight    = 250;
static const CGFloat mBtnHeight    = 30;
static const CGFloat mBtnWidth     = 110;
static const CGFloat mHeaderHeight = 40;

+ (CustomAlertView *)defaultAlert
{
    static CustomAlertView *shareCenter = nil;
 if (!shareCenter)
    {
  shareCenter = [[CustomAlertView alloc] init];
 }
 return shareCenter;
}

- (NSMutableArray *)customerViewsToBeAdd
{
    if (_customerViewsToBeAdd == nil)
    {
        _customerViewsToBeAdd = [[NSMutableArray alloc] init];
    }

    return _customerViewsToBeAdd;
}

- (id)init
{
    self = [super initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT + 20)];
    if (self)
    {
        _isShow = NO;
    }
    return self;
}

- (id)initWithTitle:(NSString*)title message:(NSString*)message delegate:(id)del cancelButtonTitle:(NSString*)cancelBtnTitle otherButtonTitles:(NSString*)otherBtnTitles, ...
{
    self = [super initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT + 20)];
    if (self)
    {
        self.delegate = del;
        self.cancelButtonTitle = cancelBtnTitle;
        self.isNeedCloseBtn = NO;

        if (!_otherButtonTitles)
        {
            va_list argList;
            if (otherBtnTitles)
            {
                self.otherButtonTitles = [NSMutableArray array];
                [self.otherButtonTitles addObject:otherBtnTitles];
            }
            va_start(argList, otherBtnTitles);
            id arg;
            while ((arg = va_arg(argList, id)))
            {
                [self.otherButtonTitles addObject:arg];
            }
        }
        self.title = title;
        self.message = message;

    }
    return self;
}

-(void)initTitle:(NSString*)title message:(NSString*)message delegate:(id)del cancelButtonTitle:(NSString*)cancelBtnTitle otherButtonTitles:(NSString*)otherBtnTitles, ...
{
    if (self)
    {
        self.delegate = del;
        self.cancelButtonTitle = cancelBtnTitle;
        self.isNeedCloseBtn = NO;

        if (!_otherButtonTitles)
        {
            va_list argList;
            if (otherBtnTitles)
            {
                self.otherButtonTitles = [NSMutableArray array];
                [self.otherButtonTitles addObject:otherBtnTitles];
            }
            va_start(argList, otherBtnTitles);
            id arg;
            while ((arg = va_arg(argList, id)))
            {
                [self.otherButtonTitles addObject:arg];
            }
        }
        self.title = title;
        self.message = message;
    }
}

- (void) layoutSubviews
{
    [super layoutSubviews];

    for (UIView *view in [self subviews])
    {
        [view removeFromSuperview];
    }

    UIView *bgView = [[UIView alloc] initWithFrame:self.frame];
    [bgView setBackgroundColor:[UIColor blackColor]];
    [bgView setAlpha:0.4];
    [self addSubview:bgView];
    [bgView release];

    if (!_backView)
    {
        _backView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, mWidth, mHeight)];
        _backView.opaque = NO;
        _backView.backgroundColor     = [UIColor whiteColor];
        _backView.layer.shadowOffset  = CGSizeMake(1, 1);
        _backView.layer.shadowRadius  = 2.0;
        _backView.layer.shadowColor   = [UIColor grayColor].CGColor;
        _backView.layer.shadowOpacity = 0.8;
        [_backView.layer setMasksToBounds:NO];
    }

    // - 设置头部显示区域
    // - 设置标题背景
    UIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, mWidth, mHeaderHeight)];
    titleView.backgroundColor = RGBA_COLOR(36, 193, 64, 1);

    CGSize titleSize = CGSizeZero;
    if (self.title && [self.title length] > 0)
    {
        titleSize = [self.title sizeWithFont:[UIFont fontWithName:@"Helvetica-Bold" size:18.0f]];
    }
    if (titleSize.width > 0)
    {
        // - 标题图片
        CGFloat startX = (titleView.frame.size.width - 40 - titleSize.width) / 2;
        UIImageView *titleImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"xxxxx.png"]];
        titleImage.frame = CGRectMake(startX, (titleView.frame.size.height - 30) / 2, 30, 30);
        self.titleIcon = titleImage;

        [titleView addSubview:titleImage];
        [titleImage release];
        startX += 40;

        // - 标题
        UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(startX, (titleView.frame.size.height - 20) / 2, titleSize.width, 20)];

        //- 标题太长的话需要处理
        if (titleLabel.frame.size.width > 250)
        {
            titleLabel.frame = CGRectMake(50, (titleView.frame.size.height - 20) / 2, mWidth - 60, 20);

            titleImage.frame = CGRectMake(5, (titleView.frame.size.height - 30) / 2, 30, 30);

        }

        titleLabel.text = self.title;
        titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:18.0f];
        titleLabel.textColor = [UIColor whiteColor];
        titleLabel.backgroundColor = [UIColor clearColor];
        self.titleLabel = titleLabel;

        [titleView addSubview:titleLabel];
        [titleLabel release];
    }else
    {
        // - 标题图片
        UIImageView *titleImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"xxxxx.png"]];
        titleImage.frame = CGRectMake((titleView.frame.size.width - 30) / 2, (titleView.frame.size.height - 30) / 2, 30, 30);
        [titleView addSubview:titleImage];
        [titleImage release];
    }

    if (self.isNeedCloseBtn)
    {
        UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(mWidth-mHeaderHeight, 0, mHeaderHeight, mHeaderHeight)];
        btn.backgroundColor = [UIColor clearColor];
        [btn setImage:[UIImage imageNamed:@"btn_close_alertview.png"] forState:UIControlStateNormal];
        [btn addTarget:self action:@selector(closeBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
        [titleView addSubview:btn];
        [btn release];
    }

    [_backView addSubview:titleView];
    self.titleBackgroundView = titleView;
    [titleView release];

    // - 设置消息显示区域
    UIScrollView *msgView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, mHeaderHeight, mWidth, (mHeight-mHeaderHeight * 2))];

    // - 设置背景颜色
    msgView.backgroundColor = [UIColor whiteColor];

    // - 内容
    CGSize messageSize = CGSizeZero;
    if (self.message && [self.message length]>0)
    {
        messageSize = [self.message sizeWithFont:[UIFont systemFontOfSize:16.0f] constrainedToSize:CGSizeMake(mWidth-20, MAXFLOAT) lineBreakMode:NSLineBreakByWordWrapping];

        if (messageSize.width > 0)
        {
            UILabel *msgLabel = [[UILabel alloc] init];
            msgLabel.font = [UIFont systemFontOfSize:16.0f];
            msgLabel.text = self.message;
            msgLabel.numberOfLines   = 0;
            msgLabel.textAlignment   = NSTextAlignmentCenter;
            msgLabel.backgroundColor = [UIColor clearColor];
            msgLabel.frame = CGRectMake(10, ((mHeight - mHeaderHeight * 2) - messageSize.height) / 2, mWidth-20, messageSize.height + 5);
            if(messageSize.height > mMaxHeight)
            {
                msgView.frame = CGRectMake(msgView.frame.origin.x, msgView.frame.origin.y, msgView.frame.size.width, mMaxHeight + 25);
                _backView.frame = CGRectMake(0, 0, mWidth, mHeaderHeight * 2 + msgView.frame.size.height);
                msgLabel.textAlignment = NSTextAlignmentLeft;
                msgLabel.frame = CGRectMake(10, 10, mWidth - 20, messageSize.height);
                msgView.contentSize = CGSizeMake(msgView.frame.size.width, msgLabel.frame.size.height + 20);
            }
            else if (messageSize.height > (mHeight-mHeaderHeight * 2) - 10)
            {
                msgView.frame = CGRectMake(msgView.frame.origin.x, msgView.frame.origin.y, msgView.frame.size.width, messageSize.height + 25);
                _backView.frame = CGRectMake(0, 0, mWidth, mHeaderHeight * 2 + msgView.frame.size.height);
                msgLabel.frame = CGRectMake(10, 10, mWidth - 20, messageSize.height + 5);
            }
            [msgView addSubview:msgLabel];
            [msgLabel release];
            [_backView addSubview:msgView];
        }
    }else{
        if (self.customerViewsToBeAdd && [self.customerViewsToBeAdd count] > 0)
        {
            CGFloat startY = 0;
            for (UIView *subView in self.customerViewsToBeAdd)
            {
                CGRect rect = subView.frame;
                rect.origin.y = startY;
                subView.frame = rect;
                [msgView addSubview:subView];
                startY += rect.size.height;
            }
            msgView.frame = CGRectMake(0, mHeaderHeight, mWidth, startY);
        }
        [_backView addSubview:msgView];
        _backView.frame = CGRectMake(0, 0, mWidth, msgView.frame.size.height + mHeaderHeight * 2 +20);
    }
    [msgView release];

    // - 设置按钮显示区域
    if (_otherButtonTitles != nil || _cancelButtonTitle != nil)
    {
        UIView *btnView = [[UIView alloc] initWithFrame:CGRectMake(0, _backView.frame.size.height-mHeaderHeight, mWidth, mHeaderHeight)];

        // - 如果只显示一个按钮,需要计算按钮的显示大小
        if (_otherButtonTitles == nil || _cancelButtonTitle == nil)
        {
            UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake((_backView.frame.size.width-mBtnWidth) /  2, 0, mBtnWidth, mBtnHeight)];
            btn.backgroundColor = RGBA_COLOR(36, 193, 64, 1);
            btn.titleLabel.font = [UIFont fontWithName:@"Helvetica" size:17.0f];
            btn.titleLabel.textColor = [UIColor whiteColor];
            [btn addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
            if (_otherButtonTitles == nil && _cancelButtonTitle != nil)
            {
                [btn setTitle:_cancelButtonTitle forState:UIControlStateNormal];
            } else
            {
                [btn setTitle:[_otherButtonTitles objectAtIndex:0] forState:UIControlStateNormal];
            }
            btn.tag = 0;
            btn.layer.cornerRadius = 5;
            [btnView addSubview:btn];
            [btn release];
        }
        else if(_otherButtonTitles && [_otherButtonTitles count] == 1)
        {
            // - 显示两个按钮
            // - 设置确定按钮的相关属性
            CGFloat startX = (_backView.frame.size.width-mBtnWidth*2-20)/2;
            UIButton *otherBtn = [[UIButton alloc]initWithFrame:CGRectMake(startX, 0, mBtnWidth, mBtnHeight)];
            otherBtn.backgroundColor = RGBA_COLOR(36, 193, 64, 1);
            otherBtn.titleLabel.font = [UIFont fontWithName:@"Helvetica" size:17.0f];
            otherBtn.titleLabel.textColor = [UIColor whiteColor];
            [otherBtn setTitle:[_otherButtonTitles objectAtIndex:0] forState:UIControlStateNormal];
            otherBtn.layer.cornerRadius = 5;
            [otherBtn addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
            otherBtn.tag = 0;
            [btnView addSubview:otherBtn];
            [otherBtn release];
            startX += mBtnWidth+20;

            // - 设置取消按钮的相关属性
            UIButton *cancelBtn = [[UIButton alloc]initWithFrame:CGRectMake(startX, 0, mBtnWidth, mBtnHeight)];
            cancelBtn.backgroundColor = RGBA_COLOR(36, 193, 64, 1);
            cancelBtn.titleLabel.font = [UIFont fontWithName:@"Helvetica" size:17.0f];
            cancelBtn.titleLabel.textColor = [UIColor whiteColor];
            [cancelBtn setTitle:_cancelButtonTitle forState:UIControlStateNormal];
            cancelBtn.layer.cornerRadius = 5;
            [cancelBtn addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
            cancelBtn.tag = 1;
            [btnView addSubview:cancelBtn];
            [cancelBtn release];
        }
        [_backView addSubview: btnView];
        [btnView release];
    }
    else
    {
        CGRect rc = _backView.frame;
        rc.size.height -= mHeaderHeight;
        _backView.frame = rc;
    }

    UIControl *touchView = [[UIControl alloc] initWithFrame:self.frame];
    [touchView addTarget:self action:@selector(touchViewClickDown) forControlEvents:UIControlEventTouchDown];
    touchView.frame = self.frame;
    [self addSubview:touchView];
    [touchView release];
    _backView.center = self.center;


    [self addSubview:_backView];

    if (!_isShow)
        [CustomAlertView exChangeOut:_backView dur:0.5];
    if (self.delegate)
    {
        if ([self.delegate respondsToSelector:@selector(willPresentCustomAlertView:)])
        {
            [self.delegate willPresentCustomAlertView:self];
        }

        [[NSNotificationCenter defaultCenter] postNotificationName:kBCAlertViewPresentNotify object:nil userInfo:nil];
    }
}
- (void)touchViewClickDown
{
    if (self.delegate)
    {
        if ([self.delegate respondsToSelector:@selector(hideCurrentKeyBoard)])
        {
            [self.delegate hideCurrentKeyBoard];
        }
    }
}

// - 在消息区域设置自定义控件
- (void)addCustomerSubview:(UIView *)view
{
    [self.customerViewsToBeAdd addObject:view];
}

- (void)buttonClicked:(id)sender
{
    UIButton *btn = (UIButton *) sender;
    _isShow = NO;
    if (btn)
    {
        if (self.delegate && [self.delegate respondsToSelector:@selector(alertView:clickedButtonAtIndex:)])
        {
            [self.delegate alertView:self clickedButtonAtIndex:btn.tag];
        }
        [self removeFromSuperview];
    }
}

- (void)closeBtnClicked:(id)sender
{
    _isShow = NO;
    if (self.delegate && [self.delegate respondsToSelector:@selector(alertViewClosed:)])
    {
        [self.delegate alertViewClosed:self];
    }
    [self removeFromSuperview];
}

- (void)show
{
    [self layoutSubviews];
    if (!_isShow)
        [[[UIApplication sharedApplication].delegate window]  addSubview:self];        
    _isShow = YES;
}

- (void)dealloc
{
    [_backView release];
    [_customerViewsToBeAdd release];
    self.titleLabel = nil;
    self.titleBackgroundView = nil;
    self.titleIcon = nil;

    [super dealloc];  
}

// - alertview弹出动画
+ (void)exChangeOut:(UIView *)changeOutView dur:(CFTimeInterval)dur
{
    CAKeyframeAnimation * animation;
    animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];

    animation.duration = dur;
    animation.removedOnCompletion = NO;
    animation.fillMode = kCAFillModeForwards;

    NSMutableArray *values = [NSMutableArray array];

    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)]];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.2, 1.2, 1.0)]];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 0.9)]];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];

    animation.values = values;
    animation.timingFunction = [CAMediaTimingFunction functionWithName: @"easeInEaseOut"];

    [changeOutView.layer addAnimation:animation forKey:nil];
}

@end

http://www.bkjia.com/IOSjc/932133.htmlwww.bkjia.comtruehttp://www.bkjia.com/IOSjc/932133.htmlTechArticleiOS自定义alertView,继承自UIView,可以添加子视图,标题图片+文字
自定义alertView,继承自UIView,可以在消息区域添加子视图:addCustomerSubview
标题可以…

返回textFieldIndex角标对应的文本框。

Ios代码

取出文本框文字

6.showsTouchWhenHighlighted

2.attributedText:设置标签属性文本。

_textView.text=@”Now is the time for all good developers to come
toserve their country.\n\nNow is the time for all good developers to
come toserve their country.”;//设置它显示的内容

view.tag=0;

Ios代码

7.adjustsFontSizeToFitWidth:文字内容自适应标签宽度。

13.//插入视图在某个视图之下

3.//将一个视图移到前面

btn.contentHorizontalAlignment = UIControlContentHorizonAlignmentLeft;

当一次触摸在控件窗口之外拖动时。

3.
当UIAlertView完全出现的时候调用

message:nil

– (void)willPresentAlertView:(UIAlertView*)alertView;

6.enabled:设置文字内容是否可变。

3.UIControlEventTouchDownRepeat多次按下

4.textAlignment:设置标签文本对齐方式。

设置视图的透明度.默认为1.

9.CGAffineTransform transform

7.UIControlEventTouchUpInside

1> 表示控件的中点(以父控件的左上角为坐标原点)

默认为YES,表示当父视图尺寸改变时,子视图也会随着改变。

10.minimumScaleFactor:设置最小字体,与minimumFontSize相同,minimumFontSize在IOS
6后不能使用。

//设置对应状态的标题阴影颜色

[alertshow];

Ios代码

实现效果:

当按钮禁用的情况下,图像的颜色会被画深一点,默认为YES。

*CGAffineTransformRotate(CGAffineTransform t, CGFloat angle)

3.numberOfButtons (只读)

iOS代码

创建一个旋转角度为angle的形变值

*CGAffineTransformMakeRotation(CGFloat angle)

label4.baselineAdjustment = UIBaselineAdjustmentNone;

10.insertSubview:atIndex:

5.2
UIAlertViewStylePlainTextInput

NSLog(@”UIAlertView中取消按钮的角标是%d”,alert.cancelButtonIndex);

label.lineBreakMode=NSLineBreakByTruncatingMiddle;

– (void)setTitleColor:(UIColor*)color forState:(UIControlState)state;

view.alpha=0;

3.hidden

{

4.
当UIAlertView即将消失的时候调用

当文本控件中开始编辑时发送通知。

5. alertViewStyle

返回当前视图的窗口。(窗口)

NSMutableAttributedString *textLabelStr = [[NSMutableAttributedString alloc] initWithString:text];

}

一.UIView属性

UIControlStateSelected        //选中状态

[alert dismissWithClickedButtonIndex:0 animated:YES];

{

4.userInteractionEnabled

10. 为UIAlertView添加子视图

12.autoresizesSubviews

alert.alertViewStyle=UIAlertViewStylePlainTextInput;

view.hidden=YES;

NSString *text = @”first”;

//设置对应状态的标题颜色

1.//加一个视图到一个视图里面

8.CGRect bounds

5.//将一个视图推送到背后

15.preferredMaxLayoutWidth:优先选择标签布局的最大宽度。

label.numberOfLines=0

UIButtonTypeContactAdd         //添加按钮

UIControlStateReserved        //保留状态

UIButtonTypeDetailDisclosure   //细节展示按钮

2.addSubview:

[alertViewshow];

UIViewContentModeAspectToFit  
按照原长宽比例(长和宽等比例增长),完全显示全部内容。这样容易照成左右或者上下留有空白。

7.手动的取消对话框

当文本控件中的文本被改变时发送通知。

下面的代码用来演示如何为UIAlertview对象添加子视图的方法。

button.showsTouchWhenHighlighted=YES;点击时的闪光效果会被前景图片遮住中间部分;

UIButtonTypeCustom            //自定义类型

– (void)setTitle:(NSString*)title forState:(UIControlState)state;

{

1> 表示控件的位置和尺寸(以自己的左上角位坐标原点,位置永远是(0,0))

{

label.lineBreakMode = NSLineBreakByTruncatingMiddle;中间的内容以……方式省略,显示头尾的文字内容。

通知所有事件

中按照自己的需要修改或添加即可,比如需要将消息文本左对齐,下面的代码即可实现:

UIControlStateNormal          //正常状态

效果:

五.UIControl事件

当按钮高亮的情况下,图像的颜色会被画深一点,默认为YES。

delegate:nil

btn.contentEdgeInsets = UIEdgeInsetsMake(0,10, 0, 0);

UIButtonTypeInfoLight          //浅色背景的信息按钮

//默认为0,用来标记视图的

_textView.textColor= [UIColorblackColor];//设置textview里面的字体颜色

//默认为YES,如果设置为No,view就不能和用户交互了。(即不能响应事件)

6. – (UITextField
*)textFieldAtIndex:(NSInteger)textFieldIndex

所有在控件之内触摸抬起事件。

10.UIControlEventTouchChanged

label.lineBreakMode = NSLineBreakByTruncatingHead;前面部分文字以……方式省略,显示尾部文字内容。

UIControlStateHighlighted     //高亮状态

7.CGPoint center

当一次触摸从控件窗口之外拖动到内部时。

2.Message

UIAlertView*alert = [[UIAlertViewalloc]initWithTitle:@”提示”

– (void)alertView:(UIAlertView*)alertView
didDismissWithButtonIndex:(NSInteger)buttonIndex;

UIViewContentModeAspectToFill
 按照原长宽比例填充,不完全显示全部内容。这样内容可能溢出,但整个视图不会留有空白。

17. backgroundColor背景颜色

默认为UIViewAutoresizingNone,不会自动伸缩。

当文本控件中编辑结束时发送通知。

4.adjustsImageWhenDisabled

– (void)setBackgroundImage:(UIImage*)image
forState:(UIControlState)state;

6.contentEdgeInsets

activeView.center = CGPointMake(alert.bounds.size.width/ 2.0f,
alert.bounds.size.height – 40.0f);

view.alpha=1;

UIAlertView*alert =
[[UIAlertViewalloc]initWithTitle:@”产品信息展示”message:p.namedelegate:nilcancelButtonTitle:@”取消”otherButtonTitles:@”确定”,nil];

view.clipsToBounds=YES;

返回UIAlertView上有多少按钮.

//不透明

作为UIAlertView的代理,必须遵守UIAlertViewDelegate。

6.UIControlEventTouchUpOutside//按钮外面松开

– (void)setTitleShadowColor:(UIColor*)color
forState:(UIControlState)state;

}

_textView.attributedText=
[[NSAttributedStringalloc]initWithString:@”attributedText__-abc”];//可以方便将文本插入到UITextView中。

UILabel*label = (UILabel*) view;

1.当点击UIAlertView上的按钮时,就会调用,并且当方法调完后,UIAlertView会自动消失。

11.//插入视图在某个视图之上

13.UIControlEventEditingDidEnd

{

使文字距离左边框保持10个像素的距离。

3.UIButton常用属性

12.UIControlEventEditingChanged

3.font:设置标签文本字体。

获取根视图的superview和window时,需要注意,在viewdidload中是获取不到的,viewdidload只是视图加载完成,并没有添加到窗口中,因此需要在viewDidAppear方法中才能获取到。那时候视图才被添加到窗口中。

//设置背景颜色为红色

当控件的值发生改变时,发送通知。用于滑块、分段控件、以及其他取值的控件。你可以配置滑块控件何时发送通知,在滑块被放下时发送,或者在被拖动时发送。

label.font = [UIFont fontWithName:@”Arial”size:16];

*CGAffineTransformMakeScale(CGFloat sx, CGFloat sy)

//默认是NO,当设置为yes,视图就看不见了。

9.numberOfLines:标签最多显示行数。

获取或设置UIAlertView上的消息

8.adjustsLetterSpacingToFitWidth:根据字母的间隔自适应标签宽度,超出部分以……显示。

}

– (void)willPresentAlertView:(UIAlertView *)alertView

4.UIControlEventTouchDragOutside

1.UIControlEventTouchDown

alertView.message=@”M”;

self.view.backgroundColor= [UIColorredColor];

通知所有关于文本编辑的事件。

[textLabelStr setAttributes:@{NSForegroundColorAttributeName : [UIColor lightGrayColor],

6.sendSubviewToBack:

3.           textColor:设置textView中文本的颜色

4.           textAlignment:设置textView的文本的排列方式

-(void) willPresentAlertView:(UIAlertView *)alertView

otherButtonTitles:nil];

8. delegate

9.UIControlEventTouchCancel

当一次触摸从控件窗口内部拖动到外部时。

但是问题又出来,此时文字会紧贴到左边框,我们可以设置

1.Title

//弹出UIAlertView

2> 修改这个属性,只能调整控件的尺寸

UIControlStateApplication     //

2.Uibutton类型:

三.UILabel属性

14.userInteractionEnabled:设置标签是否忽略或移除用户交互。默认为NO。

btn.textLabel.textAlignment= UITextAlignmentLeft

2> 修改这个属性,可以调整控件的位置

二.UITextView

7.//把视图移除

You can leave a response, or trackback from your own site.

Leave a Reply

网站地图xml地图