ScrollViews will not resize - ios

I have struggled with this and maybe I am not understanding how scrollviews work. I am trying to calculate the height automatically for 'self.description' however nothing I do seems to work. I have changed values from the scrollviewframe even tried changing the values using frame.size.height. however it still does not calculate the height. Am i missing something?
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
if (self) {
CGRect scrollViewFrame = CGRectMake(0, 0, 460, 590);
scrollView = [[UIScrollView alloc] initWithFrame:scrollViewFrame];
[self.contentView addSubview:self.scrollView];
[scrollView setCanCancelContentTouches:NO];
scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
scrollView.clipsToBounds = YES;
scrollView.scrollEnabled = YES;
scrollView.pagingEnabled = NO;
self.label = [[UILabel alloc] initWithFrame:CGRectMake(10.0, 67.0, 290, 50)];
self.label.font= [UIFont fontWithName:#"Helvetica-Bold" size:20];
self.label.textColor = [UIColor colorWithRed:33.0f/255.0f green:74.0f/255.0f blue:146.0f/255.0f alpha:1.0f];
self.label.numberOfLines = 0;
self.label.lineBreakMode = NSLineBreakByWordWrapping;
self.label.backgroundColor = [UIColor whiteColor];
[scrollView addSubview:self.label];
//[self.contentView addSubview:self.label];
self.description = [[UILabel alloc] initWithFrame:CGRectMake(10.0, 380.0, 300, 9999)];
self.description.font= [UIFont fontWithName:#"Helvetica-Light" size:15];
self.description.textColor = [UIColor blackColor];
self.description.textAlignment = NSTextAlignmentJustified;
self.description.numberOfLines = 0;
self.description.lineBreakMode = NSLineBreakByWordWrapping;
self.description.backgroundColor = [UIColor whiteColor];
[scrollView addSubview:self.description];
//[self.contentView addSubview:self.description];
self.image = [[UIImageView alloc] initWithFrame:CGRectMake(20, 130, 280, 228)];
self.image.clipsToBounds = YES;
[scrollView addSubview:self.image];
//[self.contentView addSubview:self.image];
float hgt=0; for (UIView *view in scrollView.subviews) hgt+=view.frame.size.height;
[scrollView setContentSize:CGSizeMake(scrollView.frame.size.width,hgt)];
self.backgroundColor = [UIColor whiteColor];
}
}

Are you trying to resize scrollview or the content size of the scroll?
If you like to resize scrollview, the self.contentView aren't resized and if it is not bigger or equal to scrollview, probably it's your issue.

float contentHeight = 0;
contentHeight = yourLastSubview.frame.origin.x + yourLastSubview.frame.size.height;
[scrollView setContentSize:CGSizeMake(scrollView.frame.size.width,contentHeight)];
//yourLastSubview is for example your self.description, because self.description' origin.y is the largest (380)
If your scrollView.frame.size.height is bigger than contentHeight, your scrollView won't scroll. For example if your scrollView.frame = CGRectMake(0,0,320,480); and your contentHeight is 400 scrollView won't scroll, but if contentHeight = 500; it will.
If you want to enable bouncing your scrollView when the contentHeight is smaller than your scrollView Height use this: scrollView.alwaysBounceVertical = YES;

Related

Create UIView programmatically with Objective-C to work in both portrait and landscape

I've to create a view in objective c with two labels on it, label1 has single line and label2 is multi line based on content.
Based on content in the labels I want to adjust view height how can I do that?
Width of the view should be 20 left and right to screen width with below code I can show in portrait but in landscape it was not coming properly, It crops on the right side. How can I do show that right 20 for landscape?
Portrait
Landscape
UIView *emptyTreeView = [[UIView alloc] initWithFrame:CGRectMake(20,20,self.view.frame.size.width - 40,400)];
UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(30.0, 30.0, self.view.frame.size.width - 100, 30.0)];
UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(30.0, 90.0, self.view.frame.size.width - 100, 100.0)];
emptyTreeView.backgroundColor=[UIColor blueColor];
label1.backgroundColor = [UIColor redColor];
label1.textAlignment = NSTextAlignmentCenter;
label1.textColor = [UIColor blackColor];
label1.font = [UIFont boldSystemFontOfSize:18];
label1.numberOfLines = 0;
label1.text = #"The Page Cannot be displayed.";
label2.backgroundColor = [UIColor whiteColor];
label2.textAlignment = NSTextAlignmentCenter;
label2.textColor = [UIColor grayColor];
label2.font = [UIFont systemFontOfSize:15];
label2.numberOfLines = 0;
label2.text = #"Please use this feature or contact your internal contact person directly.";
[emptyTreeView addSubview:label1];
[emptyTreeView addSubview:label2];
[self.view addSubview:emptyTreeView];
Am I doing anything wrong?
A few observations:
Do not add subviews in viewDidLayoutSubviews. That is only for adjusting frame values.
If you refer to self.view, reference its bounds, not its frame. The former is for coordinates of subviews within self.view. The latter is in the coordinate system of its superview (which might not introduce any differences right now, but is just the wrong coordinate system.
If you want the view to resize on rotation, set its autoresizingMask, e.g.
emptyTreeView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin;
Or
emptyTreeView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
Nowadays, setting frame values and autoresizing masks is a bit of an anachronism. We would generally use constraints, e.g.
- (void)viewDidLoad {
[super viewDidLoad];
UIView *emptyTreeView = [[UIView alloc] init];
UILabel *label1 = [[UILabel alloc] init];
UILabel *label2 = [[UILabel alloc] init];
emptyTreeView.backgroundColor = [UIColor blueColor];
label1.backgroundColor = [UIColor redColor];
label1.textAlignment = NSTextAlignmentCenter;
label1.textColor = [UIColor blackColor];
label1.font = [UIFont boldSystemFontOfSize:18];
label1.numberOfLines = 0;
label1.text = #"The Page Cannot be displayed.";
label2.backgroundColor = [UIColor whiteColor];
label2.textAlignment = NSTextAlignmentCenter;
label2.textColor = [UIColor grayColor];
label2.font = [UIFont systemFontOfSize:15];
label2.numberOfLines = 0;
label2.text = #"Please use this feature or contact your internal contact person directly.";
[emptyTreeView addSubview:label1];
[emptyTreeView addSubview:label2];
[self.view addSubview:emptyTreeView];
emptyTreeView.translatesAutoresizingMaskIntoConstraints = false;
label1.translatesAutoresizingMaskIntoConstraints = false;
label2.translatesAutoresizingMaskIntoConstraints = false;
[NSLayoutConstraint activateConstraints:#[
[emptyTreeView.leftAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.leftAnchor constant:20],
[emptyTreeView.rightAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.rightAnchor constant:-10],
[emptyTreeView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor constant:20],
[label1.leftAnchor constraintEqualToAnchor:emptyTreeView.leftAnchor constant:20],
[label1.rightAnchor constraintEqualToAnchor:emptyTreeView.rightAnchor constant:-20],
[label1.topAnchor constraintEqualToAnchor:emptyTreeView.topAnchor constant:20],
[label2.leftAnchor constraintEqualToAnchor:emptyTreeView.leftAnchor constant:20],
[label2.rightAnchor constraintEqualToAnchor:emptyTreeView.rightAnchor constant:-20],
[label2.topAnchor constraintEqualToAnchor:label1.bottomAnchor constant:20],
[emptyTreeView.bottomAnchor constraintEqualToAnchor:label2.bottomAnchor constant:20]
]];
}
Note the translatesAutoresizingMaskIntoConstraints is false and the constraints.

iOS FadeIn/FadeOut during paging

I have an UIScrollView with views inside that I can scroll horizontally. During the scroll I would like to add a fade out on the view which is going out of the screen and a fade in on the view which is going in the screen.
Here my code :
for (int i = 0; i <textEntries.count; i++)
{
CGRect frame;
frame.origin.x = self.scrollView.frame.size.width * i + 5;
frame.size.width = self.scrollView.frame.size.width - 10;
frame.size.height = self.scrollView.frame.size.height - 10;
self.scrollView.pagingEnabled = YES;
UIView *subview = [[UIView alloc] initWithFrame:frame];
if([[colorEntries objectAtIndex:i] isEqualToString:#"violet"]){
subview.backgroundColor = [UIColor colorWithRed:(147/255.0) green:(90/255.0) blue:(255/255.0) alpha:1];
} else {
subview.backgroundColor = [UIColor colorWithRed:(100/255.0) green:(166/255.0) blue:(255/255.0) alpha:1];
}
subview.layer.cornerRadius = 5;
[self.scrollView addSubview:subview];
UITextView *noteLabel = [[UITextView alloc] init];
noteLabel.frame = CGRectMake(0, 0, self.scrollView.frame.size.width - 20, self.scrollView.frame.size.height -20);
noteLabel.text = [textEntries objectAtIndex:i];
noteLabel.userInteractionEnabled = NO;
noteLabel.backgroundColor = [UIColor clearColor];
noteLabel.contentInset = UIEdgeInsetsMake(20,20,20,20);
noteLabel.font = [UIFont fontWithName:#"HelveticaNeue-Bold" size:40];
[noteLabel setTextColor:[UIColor whiteColor]];
[subview addSubview:noteLabel];
[noteLabel addObserver:self forKeyPath:#"contentSize" options:(NSKeyValueObservingOptionNew) context:NULL];
}
Could you help me to build this fadeIn/FadeOut effect ?
Thanks!

Autoresize UIScrollView To Fit UILabel Text

I have been searching for quite a while now, and every answer I find doesn't seem to work. I have a view, code below, that holds a bunch of text that is pulled from a YouTube video description from another view. Obviously ever video's descriptions are of different length, which is what poses the problem. I want to make it that the scrollview only scrolls down to about 10 pixels after the last text line of the label.
In this code, I don't have it doing that, I have it at a fixed size.
Can ANYONE help? I have been searching for days now, and I can seem to find a proper solution.
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
VideoDescription = [VideoDescription stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
//int a = VideoDescription.length;
//NSLog([NSString stringWithFormat:#"%i", a]);
if(VideoDescription.length < 310)
{
VideoDescription = [VideoDescription stringByAppendingString:#"\n_______________________________________________"];
VideoDescription = [VideoDescription stringByAppendingString:#"\n\nFor the best viewing experience, please use WiFi."];
VideoDescription = [VideoDescription stringByAppendingString:#"\n\nWant an app like this for your YouTube Channel? Go to www.apps4tubers.com to find out how you can get one!"];
VideoDescription = [VideoDescription stringByAppendingString:#"\n\nDon't forget to rate this app! Love it? Hate it? Regardless we love to hear your comments and suggestions!"];
}
else if(VideoDescription.length < 380)
{
VideoDescription = [VideoDescription stringByAppendingString:#"\n_______________________________________________"];
VideoDescription = [VideoDescription stringByAppendingString:#"\n\nFor the best viewing experience, please use WiFi."];
VideoDescription = [VideoDescription stringByAppendingString:#"\n\nWant an app like this for your YouTube Channel? Go to www.apps4tubers.com to find out how you can get one!"];
}
else if(VideoDescription.length > 379 && VideoDescription.length < 410)
{
VideoDescription = [VideoDescription stringByAppendingString:#"\n_______________________________________________"];
VideoDescription = [VideoDescription stringByAppendingString:#"\n\nWant an app like this for your YouTube Channel? Go to www.apps4tubers.com to find out how you can get one!"];
}
else
{
VideoDescription = [VideoDescription stringByAppendingString:#"\n\nFor the best viewing experience, please use WiFi."];
}
CGRect scrollViewFrame = CGRectMake(0, 0, 320, 480);
TheView = [[UIScrollView alloc] initWithFrame:scrollViewFrame];
CGSize scrollViewContentSize = CGSizeMake(320, 650);
[TheView setContentSize:scrollViewContentSize];
[TheView setPagingEnabled:NO];
TheView.showsHorizontalScrollIndicator = NO;
TheView.showsVerticalScrollIndicator = YES;
TheView.bounces = NO;
[self.view addSubview:TheView];
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:#"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
self.navigationItem.backBarButtonItem = backButton;
Background = [[UILabel alloc] initWithFrame: CGRectMake(00, 25, 1000, 1600)];
Background.center = CGPointMake(00, 00);
Background.backgroundColor = [self colorWithHexString:#"111625"];
[TheView addSubview: Background];
VideoDecrip = [[UILabel alloc] initWithFrame: CGRectMake(00, 25, 320, 400)];
VideoDecrip.center = CGPointMake(160.5, 400);
VideoDecrip.text = VideoDescription;
VideoDecrip.font = [UIFont fontWithName: #"Cochin-Bold" size: 13.5];
VideoDecrip.textColor = [self colorWithHexString:#"D1E751"];
VideoDecrip.shadowColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:.35];
VideoDecrip.layer.shadowOpacity = 0;
VideoDecrip.shadowOffset = CGSizeMake(1,1);
VideoDecrip.layer.masksToBounds = NO;
VideoDecrip.backgroundColor = [UIColor clearColor];
VideoDecrip.textAlignment = NSLineBreakByWordWrapping;
VideoDecrip.adjustsFontSizeToFitWidth = YES;
VideoDecrip.numberOfLines = 0;
[VideoDecrip sizeToFit];
[TheView addSubview: VideoDecrip];
NSLog(#"%i", VideoDecrip.text.length);
VideoTitleBorder = [[UILabel alloc] initWithFrame: CGRectMake(00, 25, 320.5, 30)];
VideoTitleBorder.center = CGPointMake(160, 182.5);
VideoTitleBorder.shadowOffset = CGSizeMake(1,1);
VideoTitleBorder.backgroundColor = [self colorWithHexString:#"0B486B"];
VideoTitleBorder.layer.borderColor = [UIColor darkGrayColor].CGColor;
VideoTitleBorder.layer.borderWidth = .4;
[TheView addSubview: VideoTitleBorder];
VideoTitle = [[UILabel alloc] initWithFrame: CGRectMake(00, 25, 320, 26)];
VideoTitle.text = VidTitle;
if([VideoTitle.text length] < 20)
{
VideoTitle.center = CGPointMake(160, 182.5);
}
else if([VideoTitle.text length] < 30)
{
VideoTitle.center = CGPointMake(160, 182);
}
else
{
VideoTitle.center = CGPointMake(160, 179);
}
VideoTitle.font = [UIFont fontWithName: #"ArialRoundedMTBold" size: 25];
VideoTitle.textColor = [self colorWithHexString:#"BEF202"];
VideoTitle.shadowColor = [UIColor blackColor];
VideoTitle.backgroundColor = [UIColor clearColor];
VideoTitle.shadowOffset = CGSizeMake(1,1);
VideoTitle.textAlignment = NSTextAlignmentCenter;
VideoTitle.adjustsFontSizeToFitWidth = YES;
[TheView addSubview: VideoTitle];
VideoTitleBorder2 = [[UILabel alloc] initWithFrame: CGRectMake(00, 25, 160, 500)];
VideoTitleBorder2.center = CGPointMake(400, 125);
VideoTitleBorder2.shadowOffset = CGSizeMake(1,1);
VideoTitleBorder2.backgroundColor = [self colorWithHexString:#"0B486B"];
VideoTitleBorder2.layer.borderColor = [UIColor darkGrayColor].CGColor;
VideoTitleBorder2.layer.borderWidth = 2.0;
[self.view addSubview: VideoTitleBorder2];
In short, you can use the NSString method -sizeWithFont:forWidth:lineBreakMode: to determine how tall the string will render in a container with the given width and line break mode. You can use that to size your UILabel and to set the scrollview's contentsize appropriately.
Try using sizeToFiton the label, then setting the scrollView's contentSize:
[label sizeToFit];
[scrollView setContentSize:CGSizeMake(CGRectGetWidth(self.view.frame), CGRectGetHeight(label.frame) + 10)];
Using sizeToFit is really nice, just make sure your label is already the right width before you call it.

How to autoresize UIScrollView

In my app is an infopage. The textllength could differ due to localization. Beside that has a 3.5" screen less real-estate than a 4" display. So what I try to achieve is that the UILabel "grows" inside a ScrollView and the Scrollview adapts to the screen.
This is my code:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// Create a ScrollView and a label
UIScrollView *infoScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(20.0f, 55.0f, 300.0f, 400.0f)];
CGRect labelFrame = CGRectMake(0, 0, 280, 800);
UILabel *infoLabel = [[UILabel alloc] initWithFrame:labelFrame];
NSString *labelText = NSLocalizedString (#"InfoText",#"");
[infoLabel setText:labelText];
// Tell the label to use an unlimited number of lines
[infoLabel setNumberOfLines:0];
[infoLabel setBackgroundColor:[UIColor clearColor]];
[infoLabel setFont:[UIFont boldSystemFontOfSize:17]];
infoLabel.textColor = [UIColor colorWithRed:255 green:255 blue:255 alpha:1.0];
[infoLabel sizeToFit];
infoScroll.contentSize = CGSizeMake(infoScroll.contentSize.width, infoLabel.frame.size.height);
[infoScroll addSubview:infoLabel];
[self.view addSubview:infoScroll];
}
Please advice, thanks in advance
Modify your function by below way:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// Create a ScrollView and a label
UIScrollView *infoScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(20.0f, 55.0f, self.view.frame.size.width - 20.0, self.view.frame.size.height - 55)];
infoScroll.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
UILabel *infoLabel = [[UILabel alloc] initWithFrame:CGRectZero];
infoLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
NSString *labelText = NSLocalizedString (#"InfoText",#"");
[infoLabel setText:labelText];
// Tell the label to use an unlimited number of lines
[infoLabel setNumberOfLines:0];
[infoLabel setBackgroundColor:[UIColor clearColor]];
[infoLabel setFont:[UIFont boldSystemFontOfSize:17]];
infoLabel.textColor = [UIColor colorWithRed:255 green:255 blue:255 alpha:1.0];
//[infoLabel sizeToFit];
CGSize infoLabelSize = [infoLabel.text sizeWithFont:infoLabel.font
constrainedToSize:CGSizeMake(infoScroll.frame.size.width, 5000)
lineBreakMode:UILineBreakModeWordWrap];
infoLabel.frame = CGRectMake(0, 0, infoLabelSize.width, infoLabelSize.height);
infoScroll.contentSize = infoLabelSize;
[infoScroll addSubview:infoLabel];
[self.view addSubview:infoScroll];
}

Auto position subviews of UINavigationBar's titleView

I have a custom titleView for displaying Navigation title and sub-title.
The title font is bigger than sub-title.
Here's what I have now:
CGRect headerTitleSubtitleFrame = CGRectMake(0, 0, 200, 44);
UIView* _headerTitleSubtitleView = [[[UILabel alloc] initWithFrame:headerTitleSubtitleFrame] autorelease];
_headerTitleSubtitleView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
_headerTitleSubtitleView.backgroundColor = [UIColor clearColor];
_headerTitleSubtitleView.autoresizesSubviews = YES;
CGRect titleFrame = CGRectMake(0, 0, 200, 24);
UILabel *titleView = [[[UILabel alloc] initWithFrame:titleFrame] autorelease];
titleView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
titleView.backgroundColor = [UIColor clearColor];
titleView.font = [UIFont boldSystemFontOfSize:20];
titleView.textAlignment = UITextAlignmentCenter;
titleView.textColor = [UIColor whiteColor];
titleView.shadowColor = [UIColor darkGrayColor];
titleView.shadowOffset = CGSizeMake(0, -1);
titleView.text = #"Title";
titleView.adjustsFontSizeToFitWidth = YES;
CGRect subtitleFrame = CGRectMake(0, 24, 200, 20);
UILabel *subtitleView = [[[UILabel alloc] initWithFrame:subtitleFrame] autorelease];
subtitleView.backgroundColor = [UIColor clearColor];
subtitleView.font = [UIFont boldSystemFontOfSize:13];
subtitleView.textAlignment = UITextAlignmentCenter;
subtitleView.textColor = [UIColor whiteColor];
subtitleView.shadowColor = [UIColor darkGrayColor];
subtitleView.shadowOffset = CGSizeMake(0, -1);
subtitleView.text = #"subtitle";
subtitleView.adjustsFontSizeToFitWidth = YES;
_headerTitleSubtitleView.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleBottomMargin);
[_headerTitleSubtitleView addSubview:titleView];
[_headerTitleSubtitleView addSubview:subtitleView];
self.navigationItem.titleView = _headerTitleSubtitleView;
I want to have the ability to remove subTitleView at some point in my code,
but that makes the titleView look out of center (vertically).
So my question is, how would you implement auto-positioning here?
should I use layoutSubviews ?
if so, what would be the proper way to override it?
I thought that when the container view has an autoresizingMask it will adjust it's size according to the "total" size of it's subviews (?).
Thanks
I was able to resolve this issue by creating a separate view class and
implement layoutSubviews.
Title label subview is always attached.
Subtitle label subview can be removed/added whenever need - which
will call layoutSubViews to make re-position the Title label view in center.
- (id)initWithFrame:(CGRect)frame
{
CGRect containerFrame = CGRectMake(0, 0, 200, 44);
self = [super initWithFrame:containerFrame];
if (self) {
self.backgroundColor = [UIColor clearColor];
self.autoresizesSubviews = YES;
_title = [[UILabel alloc] initWithFrame:CGRectZero];
_title.backgroundColor = [UIColor clearColor];
_title.font = [UIFont boldSystemFontOfSize:20];
_title.textAlignment = UITextAlignmentCenter;
_title.textColor = [UIColor whiteColor];
_title.shadowColor = [UIColor darkGrayColor];
_title.shadowOffset = CGSizeMake(0, -1);
_title.adjustsFontSizeToFitWidth = YES;
_subTitle = [[UILabel alloc] initWithFrame:CGRectZero];
_subTitle.backgroundColor = [UIColor clearColor];
_subTitle.font = [UIFont boldSystemFontOfSize:13];
_subTitle.textAlignment = UITextAlignmentCenter;
_subTitle.textColor = [UIColor whiteColor];
_subTitle.shadowColor = [UIColor darkGrayColor];
_subTitle.shadowOffset = CGSizeMake(0, -1);
_subTitle.adjustsFontSizeToFitWidth = YES;
self.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleBottomMargin);
[self addSubview:_title];
}
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
if (([self.subviews count] > 1) && ([[self.subviews objectAtIndex:1] isKindOfClass:[UILabel class]]))
{
[[self.subviews objectAtIndex:0] setFrame:CGRectMake(0,0,200,24)];
[[self.subviews objectAtIndex:1] setFrame:CGRectMake(0,24,200,20)];
}
else
[[self.subviews objectAtIndex:0] setFrame:self.bounds];
}

Resources