Skip to content
This repository
Browse code

supports resizing of MultiFoldView

  • Loading branch information...
commit b8a7a775e2fa125421005145691d67a4e77e367f 1 parent 7b76998
honcheng authored
49  PaperFold/PaperFold/PaperFold/MultiFoldView.m
@@ -78,6 +78,55 @@ - (id)initWithFrame:(CGRect)frame foldDirection:(FoldDirection)foldDirection fol
78 78
     return self;
79 79
 }
80 80
 
  81
+- (void)setFrame:(CGRect)frame
  82
+{
  83
+    [super setFrame:frame];
  84
+
  85
+    CGRect contentViewHolderFrame = [self.contentViewHolder frame];
  86
+    contentViewHolderFrame.size.height = frame.size.height;
  87
+    [self.contentViewHolder setFrame:contentViewHolderFrame];
  88
+    
  89
+    
  90
+    for (UIView *subview in self.subviews)
  91
+    {
  92
+        if ([subview isKindOfClass:[FoldView class]]) [subview removeFromSuperview];
  93
+    }
  94
+    
  95
+    for (int i=0; i<_numberOfFolds; i++)
  96
+    {
  97
+        if (_foldDirection==FoldDirectionHorizontalLeftToRight || _foldDirection==FoldDirectionHorizontalRightToLeft)
  98
+        {
  99
+            float foldWidth = frame.size.width/self.numberOfFolds;
  100
+            FoldView *foldView = [[FoldView alloc] initWithFrame:CGRectMake(foldWidth*i,0,foldWidth,frame.size.height) foldDirection:_foldDirection];
  101
+            [foldView setTag:FOLDVIEW_TAG+i];
  102
+            [self addSubview:foldView];
  103
+        }
  104
+        else if (_foldDirection==FoldDirectionVertical)
  105
+        {
  106
+            float foldHeight = frame.size.height/self.numberOfFolds;
  107
+            FoldView *foldView = [[FoldView alloc] initWithFrame:CGRectMake(0,foldHeight*(self.numberOfFolds-i)-foldHeight,frame.size.width,foldHeight) foldDirection:_foldDirection];
  108
+            [foldView setTag:FOLDVIEW_TAG+i];
  109
+            [self addSubview:foldView];
  110
+        }
  111
+    }
  112
+    
  113
+//    for (int i=0; i<_numberOfFolds; i++)
  114
+//    {
  115
+//        if (_foldDirection==FoldDirectionHorizontalLeftToRight || _foldDirection==FoldDirectionHorizontalRightToLeft)
  116
+//        {
  117
+//            float foldWidth = frame.size.width/self.numberOfFolds;
  118
+//            FoldView *foldView = (FoldView*)[self viewWithTag:FOLDVIEW_TAG+i];
  119
+//            [foldView setFrame:CGRectMake(foldWidth*i,0,foldWidth,frame.size.height)];
  120
+//        }
  121
+//        else if (_foldDirection==FoldDirectionVertical)
  122
+//        {
  123
+//            float foldHeight = frame.size.height/self.numberOfFolds;
  124
+//            FoldView *foldView = (FoldView*)[self viewWithTag:FOLDVIEW_TAG+i];
  125
+//            [foldView setFrame:CGRectMake(0,foldHeight*(self.numberOfFolds-i)-foldHeight,frame.size.width,foldHeight)];
  126
+//        }
  127
+//    }
  128
+}
  129
+
81 130
 - (id)initWithFrame:(CGRect)frame folds:(int)folds pullFactor:(float)factor
82 131
 {
83 132
     return [self initWithFrame:frame foldDirection:FoldDirectionHorizontalRightToLeft folds:folds pullFactor:factor];

0 notes on commit b8a7a77

Please sign in to comment.
Something went wrong with that request. Please try again.