Overall open-source code record (rolling images, fixed scrolling, and burst beiser curves ),

Source: Internet
Author: User

Overall open-source code record (rolling images, fixed scrolling, and burst beiser curves ),

1: implement multiple image Scrolling on the left and right

# Import <UIKit/UIKit. h> @ protocol jzarbumdelegate <NSObject> @ optional-(void) handle :( NSInteger) index; @ end @ interface jzarbumcell: UITableViewCell @ property (nonatomic, strong) NSArray * imgurlArray; /** <image URL */@ property (nonatomic, assign) id <strong> delegate;-(id) initWithStyle :( UITableViewCellStyle) style reuseIdentifier :( NSString *) reuseIdentifier frame :( CGRect) frame; @ end
# Import "jzarbumcell. h "# import" UIImageView + WebCache. h "@ interface jzarbumcell () {UIScrollView * _ scrollView;} @ end @ implementation jzarbumcell-(id) initWithStyle :( strong) style reuseIdentifier :( NSString *) reuseIdentifier frame :( CGRect) frame {self = [super initWithStyle: style reuseIdentifier: reuseIdentifier]; if (self) {// create scrollview _ scrollView = [[UIScrollView alloc] initWithFrame: CGRectMake (5, 0, frame. size. width, frame. size. height)]; _ scrollView. showsHorizontalScrollIndicator = NO; [self addSubview: _ scrollView]; // Add an image for (int I = 0; I <10; ++ I) {UIImageView * imageView = [[UIImageView alloc] initWithFrame: CGRectMake (screen_width * 2/5 + 5) * I, 5, screen_width * 2/5, frame. size. height-10)]; imageView. layer. masksToBounds = YES; imageView. layer. cornerRadius = 5; // [imageView setImage: [UIImage imageNamed: @ "lesson_default"]; imageView. tag = I + 20; optional * tap = [[UITapGestureRecognizer alloc] initWithTarget: self action: @ selector (OnTapImage :)]; [imageView addGestureRecognizer: tap]; imageView. userInteractionEnabled = YES; [_ scrollView addSubview: imageView] ;}} return self ;}- (void) awakeFromNib {// Initialization code}-(void) setSelected :( BOOL) selected animated :( BOOL) animated {[super setSelected: selected animated: animated]; // Configure the view for the selected state}-(void) setImgurlArray :( NSArray *) imgurlArray {_ scrollView. contentSize = CGSizeMake (screen_width * 2/5 + 5) * imgurlArray. count + 5, _ scrollView. frame. size. height); for (int I = 0; I 
Static NSString * cellIndentifier = @ "courseCell1"; jzarbumcell * cell = [tableView failed: cellIndentifier]; if (cell = nil) {cell = [[jzarbumcell alloc] initWithStyle: repeated reuseIdentifier: cellIndentifier frame: CGRectMake (0, 0, screen_width, 90)]; // underline UIView * lineView = [[UIView alloc] initWithFrame: CGRectMake (0, 89.5, screen_width, 0.5)]; lineView. backgroundColor = separaterColor; [cell addSubview: lineView];} cell. delegate = self; [cell setImgurlArray: _ albumImgurlArray]; return cell;

:

 

2: The Red view and the Blue view are added to the scrollView. Drag up. The red view remains at the top of the screen, and the other continues to scroll. drag down and the red view follows.

@ Interface ViewController () <strong> @ property (weak, nonatomic) IBOutlet UIScrollView * scrollView; @ property (weak, nonatomic) IBOutlet UIView * blueView; @ property (weak, nonatomic) IBOutlet UIView * redView; @ property (weak, nonatomic) IBOutlet UIImageView * imageView; @ end @ implementation ViewController-(void) viewDidLoad {[super viewDidLoad]; self. scrollView. contentSize = CGSizeMake (0, CGRectGetMaxY (self. blueView. frame);}-(void) scrollViewDidScroll :( UIScrollView *) scrollView {CGFloat imageH = self. imageView. frame. size. height; CGFloat offsetY = scrollView. contentOffset. y; if (offsetY> = imageH) {// Add the red control to the Controller View CGRect redFrame = self. redView. frame; redFrame. origin. y = 0; self. redView. frame = redFrame; [self. view addSubview: self. redView];} else {// Add the red control to the Controller scrollView CGRe Ct redFrame = self. redView. frame; redFrame. origin. y= 140; self. redView. frame = redFrame; [self. scrollView addSubview: self. redView];} CGFloat scale = 1-(offsetY/20); scale = (scale> = 1 )? Scale: 1; self. imageView. transform = CGAffineTransformMakeScale (scale, scale);} @ end

3: Use the besell curve to draw a burst effect

# Define SCREEN_WIDTH ([UIScreen mainScreen]. bounds. size. width) @ implementation CustomView-(id) initWithFrame :( CGRect) frame {self = [super initWithFrame: frame]; if (self) {UIView * myView = [[UIView alloc] initWithFrame: CGRectMake (0, 0, SCREEN_WIDTH, 100)]; myView. backgroundColor = [UIColor redColor]; [self addSubview: myView];} return self;}-(void) drawRect :( CGRect) rect {UIColor * color = [UIColor redColor]; [color set]; // set the line color UIBezierPath * aPath = [UIBezierPath bezierPath]; aPath. lineWidth = 5.0; aPath. lineCapStyle = kCGLineCapRound; // line corner aPath. lineJoinStyle = kCGLineCapRound; // end point processing [aPath moveToPoint: CGPointMake (SCREEN_WIDTH/2-50,100)]; // left point [aPath addQuadCurveToPoint: CGPointMake (SCREEN_WIDTH/2 + 50,100) controlPoint: CGPointMake (SCREEN_WIDTH/2,150)]; // The center of the right vertex // [aPath stroke]; // draw only the line [aPath fill]; // fill}

Effect:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.